Changeset 64877


Ignore:
Timestamp:
Mar 16, 2015, 2:44:25 PM (9 years ago)
Author:
wenzeslaus
Message:

r.patch: call Rast_cell_size just once, not for every cell

Function do_patch has one more parameter but the speedup is approximately 10% (e.g., real 0m37.935s, user 0m37.405s, sys 0m0.480s to real 0m34.181s, user 0m33.697s, sys 0m0.436s).

Location:
grass/trunk/raster/r.patch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/raster/r.patch/do_patch.c

    r60839 r64877  
    2222int do_patch(void *result, void *patch,
    2323             struct Cell_stats *statf, int ncols,
    24              RASTER_MAP_TYPE out_type, int use_zero)
     24             RASTER_MAP_TYPE out_type, size_t out_cell_size, int use_zero)
    2525{
    2626    int more;
     
    5757            }                   /* NULL support */
    5858        }
    59         result = G_incr_void_ptr(result, Rast_cell_size(out_type));
    60         patch = G_incr_void_ptr(patch, Rast_cell_size(out_type));
     59        result = G_incr_void_ptr(result, out_cell_size);
     60        patch = G_incr_void_ptr(patch, out_cell_size);
    6161    }
    6262    return more;
  • grass/trunk/raster/r.patch/local_proto.h

    r32526 r64877  
    11/* do_patch.c */
    22int do_patch(void *result, void *, struct Cell_stats *, int, RASTER_MAP_TYPE,
    3             int);
     3             size_t, int);
    44/* support.c */
    55int support(char **, struct Cell_stats *, int, struct Categories *,
  • grass/trunk/raster/r.patch/main.c

    r63345 r64877  
    3535    int outfd;
    3636    RASTER_MAP_TYPE out_type, map_type;
     37    size_t out_cell_size;
    3738    struct History history;
    3839    void *presult, *patch;
     
    115116    }
    116117
     118    out_cell_size = Rast_cell_size(out_type);
     119
    117120    rname = opt2->answer;
    118121    outfd = Rast_open_new(new_name = rname, out_type);
     
    147150            Rast_get_row(infd[i], patch, row, out_type);
    148151            if (!do_patch
    149                 (presult, patch, &statf[i], ncols, out_type, use_zero))
     152                (presult, patch, &statf[i], ncols, out_type, out_cell_size,
     153                 use_zero))
    150154                break;
    151155        }
Note: See TracChangeset for help on using the changeset viewer.