[GRASS-SVN] r52522 - grass/trunk/lib/vector/diglib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 4 11:33:38 PDT 2012
Author: mmetz
Date: 2012-08-04 11:33:38 -0700 (Sat, 04 Aug 2012)
New Revision: 52522
Modified:
grass/trunk/lib/vector/diglib/plus_node.c
Log:
diglib, dig_add_node(): use faster traditional list insert
Modified: grass/trunk/lib/vector/diglib/plus_node.c
===================================================================
--- grass/trunk/lib/vector/diglib/plus_node.c 2012-08-04 18:26:03 UTC (rev 52521)
+++ grass/trunk/lib/vector/diglib/plus_node.c 2012-08-04 18:33:38 UTC (rev 52522)
@@ -57,32 +57,26 @@
if (ret == -1)
return -1;
+ angle = -9.;
if (type & GV_LINES) {
if (lineid < 0)
angle = dig_calc_end_angle(points, 0);
else
angle = dig_calc_begin_angle(points, 0);
}
- else {
- angle = -9.;
- }
G_debug(3, " angle = %f", angle);
- /* make sure the new angle is less than the empty space at end */
- node->angles[nlines] = 999.;
-
- for (i = 0; i <= nlines; i++) { /* alloced for 1 more */
- if (angle < node->angles[i]) {
- /* make room for insertion */
- for (j = nlines - 1; j >= i; j--) {
- node->angles[j + 1] = node->angles[j];
- node->lines[j + 1] = node->lines[j];
- }
- node->angles[i] = angle;
- node->lines[i] = lineid;
+ i = nlines;
+ while (i > 0) {
+ if (angle > node->angles[i - 1])
break;
- }
+ node->angles[i] = node->angles[i - 1];
+ node->lines[i] = node->lines[i - 1];
+
+ i--;
}
+ node->angles[i] = angle;
+ node->lines[i] = lineid;
node->n_lines++;
More information about the grass-commit
mailing list