[GRASS-SVN] r63308 - grass/trunk/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 30 23:47:06 PST 2014
Author: mmetz
Date: 2014-11-30 23:47:06 -0800 (Sun, 30 Nov 2014)
New Revision: 63308
Modified:
grass/trunk/lib/gis/strings.c
Log:
libgis: optimize G_chop()
Modified: grass/trunk/lib/gis/strings.c
===================================================================
--- grass/trunk/lib/gis/strings.c 2014-12-01 07:46:23 UTC (rev 63307)
+++ grass/trunk/lib/gis/strings.c 2014-12-01 07:47:06 UTC (rev 63308)
@@ -295,15 +295,17 @@
return (line);
}
- for (t = line; *t; t++) /* go to end */
+ for (t = f; *t; t++) /* go from first non white-space char to end */
;
while (isspace(*--t)) ;
*++t = '\0'; /* remove trailing white-spaces */
- t = line;
- while (*f) /* copy */
- *t++ = *f++;
- *t = '\0';
+ if (f != line) {
+ t = line;
+ while (*f) /* leading white spaces, shift */
+ *t++ = *f++;
+ *t = '\0';
+ }
return (line);
}
More information about the grass-commit
mailing list