[GRASS-SVN] r64877 - grass/trunk/raster/r.patch
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Mar 16 14:44:25 PDT 2015
Author: wenzeslaus
Date: 2015-03-16 14:44:25 -0700 (Mon, 16 Mar 2015)
New Revision: 64877
Modified:
grass/trunk/raster/r.patch/do_patch.c
grass/trunk/raster/r.patch/local_proto.h
grass/trunk/raster/r.patch/main.c
Log:
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).
Modified: grass/trunk/raster/r.patch/do_patch.c
===================================================================
--- grass/trunk/raster/r.patch/do_patch.c 2015-03-16 18:14:25 UTC (rev 64876)
+++ grass/trunk/raster/r.patch/do_patch.c 2015-03-16 21:44:25 UTC (rev 64877)
@@ -21,7 +21,7 @@
int do_patch(void *result, void *patch,
struct Cell_stats *statf, int ncols,
- RASTER_MAP_TYPE out_type, int use_zero)
+ RASTER_MAP_TYPE out_type, size_t out_cell_size, int use_zero)
{
int more;
@@ -56,8 +56,8 @@
}
} /* NULL support */
}
- result = G_incr_void_ptr(result, Rast_cell_size(out_type));
- patch = G_incr_void_ptr(patch, Rast_cell_size(out_type));
+ result = G_incr_void_ptr(result, out_cell_size);
+ patch = G_incr_void_ptr(patch, out_cell_size);
}
return more;
}
Modified: grass/trunk/raster/r.patch/local_proto.h
===================================================================
--- grass/trunk/raster/r.patch/local_proto.h 2015-03-16 18:14:25 UTC (rev 64876)
+++ grass/trunk/raster/r.patch/local_proto.h 2015-03-16 21:44:25 UTC (rev 64877)
@@ -1,6 +1,6 @@
/* do_patch.c */
int do_patch(void *result, void *, struct Cell_stats *, int, RASTER_MAP_TYPE,
- int);
+ size_t, int);
/* support.c */
int support(char **, struct Cell_stats *, int, struct Categories *,
int *, struct Colors *, int *, RASTER_MAP_TYPE);
Modified: grass/trunk/raster/r.patch/main.c
===================================================================
--- grass/trunk/raster/r.patch/main.c 2015-03-16 18:14:25 UTC (rev 64876)
+++ grass/trunk/raster/r.patch/main.c 2015-03-16 21:44:25 UTC (rev 64877)
@@ -34,6 +34,7 @@
int colr_ok;
int outfd;
RASTER_MAP_TYPE out_type, map_type;
+ size_t out_cell_size;
struct History history;
void *presult, *patch;
int nfiles;
@@ -114,6 +115,8 @@
Rast_get_cellhd(name, "", &cellhd[i]);
}
+ out_cell_size = Rast_cell_size(out_type);
+
rname = opt2->answer;
outfd = Rast_open_new(new_name = rname, out_type);
@@ -146,7 +149,8 @@
Rast_get_row(infd[i], patch, row, out_type);
if (!do_patch
- (presult, patch, &statf[i], ncols, out_type, use_zero))
+ (presult, patch, &statf[i], ncols, out_type, out_cell_size,
+ use_zero))
break;
}
Rast_put_row(outfd, presult, out_type);
More information about the grass-commit
mailing list