瀏覽代碼

vlib: enable check for duplications in dig_line_add_updated()
assuming that uplist is not large (list is reseted for every operation)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57347 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 11 年之前
父節點
當前提交
b960e256e9
共有 1 個文件被更改,包括 14 次插入7 次删除
  1. 14 7
      lib/vector/diglib/update.c

+ 14 - 7
lib/vector/diglib/update.c

@@ -36,14 +36,18 @@ void dig_line_reset_updated(struct Plus_head *Plus)
  */
 void dig_line_add_updated(struct Plus_head *Plus, int line)
 {
+    int i;
+    
     G_debug(3, "dig_line_add_updated(): line = %d", line);
 
-    /* Check if already in list
-    for (i = 0; i < Plus->uplist.n_uplines; i++)
-	if (Plus->uplist.uplines[i] == line)
+    /* Check if already in list */
+    for (i = 0; i < Plus->uplist.n_uplines; i++) {
+	if (Plus->uplist.uplines[i] == line) {
+            G_debug(3, "\tskipped");
 	    return;
-    */
-
+        }
+    }
+    
     /* Alloc space if needed */
     if (Plus->uplist.n_uplines == Plus->uplist.alloc_uplines) {
 	Plus->uplist.alloc_uplines += 1000;
@@ -82,9 +86,12 @@ void dig_node_add_updated(struct Plus_head *Plus, int node)
     G_debug(3, "dig_node_add_updated(): node = %d", node);
 
     /* Check if already in list */
-    for (i = 0; i < Plus->uplist.n_upnodes; i++)
-	if (Plus->uplist.upnodes[i] == node)
+    for (i = 0; i < Plus->uplist.n_upnodes; i++) {
+	if (abs(Plus->uplist.upnodes[i]) == abs(node)) {
+            G_debug(3, "\tskipped");
 	    return;
+        }
+    }
 
     /* Alloc space if needed */
     if (Plus->uplist.n_upnodes == Plus->uplist.alloc_upnodes) {