Changes == 0 to <= 0 for node id test
authorkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Tue, 14 Feb 2012 09:26:36 +0000 (09:26 +0000)
committerkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Tue, 14 Feb 2012 09:26:36 +0000 (09:26 +0000)
* negative node-ids are special values that denote dummy nodes
or errors, since valide nodes are positive, refusing the root
with <= 0 rather than == 0 tells the compiler that the value
of the id is (strictly) positive in the subsequent code,
allowing the compiler to perform more agressive optimisations.

git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/bp@1219 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

bp-darray.c

index ff781ec..a4aec4b 100644 (file)
@@ -441,13 +441,7 @@ int bp_darray_select(darray *da, int i,int f)
   pb x;\r
   pb *q;\r
 \r
-  if (i == 0) return -1;\r
-\r
-  if (i > da->m) {\r
-    return -1;\r
-    //printf("ERROR: m=%d i=%d\n",da->m,i);\r
-    //exit(1);\r
-  }\r
+  if (i <= 0 || i > da->m) return -1;\r
 \r
   i--;\r
 \r