From: Wouter Wijngaards Date: Mon, 10 Jan 2011 13:28:48 +0000 (+0000) Subject: - faster lruhash get_mem routine. X-Git-Tag: release-1.4.8rc1~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35c3a25896e6fa6e72fd7a78630211821d24df84;p=thirdparty%2Funbound.git - faster lruhash get_mem routine. git-svn-id: file:///svn/unbound/trunk@2366 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index 02b7218fd..11120f702 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +10 January 2011: Wouter + - faster lruhash get_mem routine. + 4 January 2011: Wouter - bug#346: remove ITAR scripts from contrib, the service is discontinued, use the root. - iana portlist updated. diff --git a/util/storage/lruhash.c b/util/storage/lruhash.c index 937a41784..c22278dda 100644 --- a/util/storage/lruhash.c +++ b/util/storage/lruhash.c @@ -492,13 +492,20 @@ size_t lruhash_get_mem(struct lruhash* table) { size_t s; - size_t i; lock_quick_lock(&table->lock); s = sizeof(struct lruhash) + table->space_used; - for(i=0; isize; i++) { - s += sizeof(struct lruhash_bin) + - lock_get_mem(&table->array[i].lock); +#ifdef USE_THREAD_DEBUG + if(table->size != 0) { + size_t i; + for(i=0; isize; i++) + s += sizeof(struct lruhash_bin) + + lock_get_mem(&table->array[i].lock); } +#else /* no THREAD_DEBUG */ + if(table->size != 0) + s += (table->size)*(sizeof(struct lruhash_bin) + + lock_get_mem(&table->array[0].lock)); +#endif lock_quick_unlock(&table->lock); s += lock_get_mem(&table->lock); return s;