Avoid calculating the hash if hashtable is empty
authorTobias Brunner <tobias@strongswan.org>
Fri, 21 Sep 2012 06:49:59 +0000 (08:49 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 21 Sep 2012 16:16:26 +0000 (18:16 +0200)
src/libstrongswan/utils/hashtable.c

index 498d107..d181d8e 100644 (file)
@@ -257,6 +257,11 @@ static void *get_internal(private_hashtable_t *this, void *key,
        void *value = NULL;
        pair_t *pair;
 
+       if (!this->count)
+       {       /* no need to calculate the hash */
+               return NULL;
+       }
+
        pair = this->table[this->hash(key) & this->mask];
        while (pair)
        {