Avoid calculating the hash if hashtable is empty
[strongswan.git] / 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)
        {