]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Merge pull request #196 from rgerhards/improve-performance
authorEric Haszlakiewicz <erh+git@nimenees.com>
Tue, 29 Sep 2015 02:25:29 +0000 (22:25 -0400)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Tue, 29 Sep 2015 02:25:29 +0000 (22:25 -0400)
Performance improvements

1  2 
json_object.c
json_object.h
linkhash.c
linkhash.h

diff --cc json_object.c
index e6bd8701a538c287423bc3606a8546852ef6c350,8dd60827ddcab5e0f0fbb0cb38467f238f85b841..6ec67a0f9ffb0b51364ad718de4b6748926519a7
@@@ -410,13 -438,14 +445,14 @@@ void json_object_object_add(struct json
        // and re-adding it, so the existing key remains valid.
        json_object *existing_value = NULL;
        struct lh_entry *existing_entry;
-       existing_entry = lh_table_lookup_entry(jso->o.c_object, (void*)key);
+       const unsigned long hash = lh_get_hash(jso->o.c_object, (void*)key);
+       existing_entry = lh_table_lookup_entry_w_hash(jso->o.c_object, (void*)key, hash);
        if (!existing_entry)
        {
-               lh_table_insert(jso->o.c_object, strdup(key), val);
+               lh_table_insert_w_hash(jso->o.c_object, strdup(key), val, hash, 0);
                return;
        }
 -      existing_value = (void *)existing_entry->v;
 +      existing_value = (json_object  *)existing_entry->v;
        if (existing_value)
                json_object_put(existing_value);
        existing_entry->v = val;
diff --cc json_object.h
Simple merge
diff --cc linkhash.c
Simple merge
diff --cc linkhash.h
Simple merge