]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
only add *DEF entries to the hash_table
authorTobias Oetiker <tobi@oetiker.ch>
Mon, 11 Mar 2013 09:56:58 +0000 (10:56 +0100)
committerTobias Oetiker <tobi@oetiker.ch>
Mon, 11 Mar 2013 09:56:58 +0000 (10:56 +0100)
src/rrd_graph_helper.c

index 7df07dd72cc107964759e480658d535104c661d5..7bfafb5aad48c0aee8cd51e45fa903e94ec96683 100644 (file)
@@ -11,6 +11,7 @@
 
 #define dprintf(...) if (gdp->debug&1) fprintf(stderr,__VA_ARGS__);
 #define dprintfparsed(...) if (gdp->debug&2) fprintf(stderr,__VA_ARGS__);
+#define dprintfhash(...) if (gdp->debug&4) fprintf(stderr,__VA_ARGS__);
 
 void initParsedArguments(parsedargs_t* pa) {
   /* initialize */
@@ -365,23 +366,10 @@ static long find_var(
 {
     /* this makes only sense for a sufficient number of items */
     long match = -1;
-    if ( im->gdes_c > 12 ) {
-        gpointer value;
-        gboolean ok = g_hash_table_lookup_extended(im->gdef_map,key,NULL,&value);
-        if (ok){
-            match = GPOINTER_TO_INT(value);
-        }
-    }
-    else {
-        long      ii;
-        for (ii = 0; ii < im->gdes_c - 1; ii++) {
-            if ((im->gdes[ii].gf == GF_DEF
-                || im->gdes[ii].gf == GF_VDEF || im->gdes[ii].gf == GF_CDEF)
-                && (strcmp(im->gdes[ii].vname, key) == 0)) {
-                match = ii;
-                break;
-            }
-        }
+    gpointer value;
+    gboolean ok = g_hash_table_lookup_extended(im->gdef_map,key,NULL,&value);
+    if (ok){
+        match = GPOINTER_TO_INT(value);
     }
     return match;
 
@@ -778,12 +766,14 @@ graph_desc_t* newGraphDescription(image_desc_t *const im,enum gf_en gf,parsedarg
   /* remember the index for faster varfind */
   char *key = gdes_fetch_key((*gdp));
   if (gdp->gf == GF_DEF && !g_hash_table_lookup_extended(im->rrd_map,key,NULL,NULL)){
+      dprintfhash("ins key %s - %ld\n",key,im->gdes_c-1);
       g_hash_table_insert(im->gdef_map,g_strdup(key),GINT_TO_POINTER(im->gdes_c-1));
   } 
   free(key);
-  g_hash_table_insert(im->gdef_map,g_strdup(gdp->vname),GINT_TO_POINTER(im->gdes_c-1));
-// g_hash_table_insert(im->gdef_map,gdp->vname,GINT_TO_POINTER(im->gdes_c-1));
-  /* and return it */
+  if (gdp->gf == GF_DEF || gdp->gf == GF_VDEF || gdp->gf == GF_CDEF){
+      dprintfhash("ins vname %s - %ld\n",gdp->vname,im->gdes_c-1);
+      g_hash_table_insert(im->gdef_map,g_strdup(gdp->vname),GINT_TO_POINTER(im->gdes_c-1));
+  }
   return gdp;
 }