]> arthur.barton.de Git - netdata.git/blobdiff - src/adaptive_resortable_list.c
Merge pull request #2021 from ktsaou/master
[netdata.git] / src / adaptive_resortable_list.c
index ac525dc6c14b3fadb418a7a3e9ab442c50821625..f74c53eae5e192845ae57ed7975eb3ee9d8d5034 100644 (file)
@@ -65,6 +65,7 @@ void arl_begin(ARL_BASE *base) {
             info("ARL '%s' has %zu fast searches and %zu slow searches. Is the source really changing so fast?"
                  , base->name, base->fast, base->slow);
 
+        /*
         if(unlikely(base->iteration % 60 == 0)) {
             info("ARL '%s' statistics: iteration %zu, expected %zu, wanted %zu, allocated %zu, fred %zu, relinkings %zu, found %zu, added %zu, fast %zu, slow %zu"
                  , base->name
@@ -82,6 +83,7 @@ void arl_begin(ARL_BASE *base) {
             // for(e = base->head; e; e = e->next) fprintf(stderr, "%s ", e->name);
             // fprintf(stderr, "\n");
         }
+        */
     }
 #endif
 
@@ -231,9 +233,14 @@ int arl_find_or_create_and_relink(ARL_BASE *base, const char *s, const char *val
         if(base->head == base->next_keyword)
             base->head = e;
     }
-    else
+    else {
         e->prev = NULL;
 
+        if(!base->head)
+            base->head = e;
+    }
+
+    // prepare the next iteration
     base->next_keyword = e->next;
     if(unlikely(!base->next_keyword))
         base->next_keyword = base->head;