From 308ec0b7df3bd61c664b1814b5442bd97a04f17d Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 21 Sep 2012 08:49:59 +0200 Subject: [PATCH] Avoid calculating the hash if hashtable is empty --- src/libstrongswan/utils/hashtable.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libstrongswan/utils/hashtable.c b/src/libstrongswan/utils/hashtable.c index 498d107e3c..d181d8ec8d 100644 --- a/src/libstrongswan/utils/hashtable.c +++ b/src/libstrongswan/utils/hashtable.c @@ -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) { -- 2.47.3