]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- faster lruhash get_mem routine.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 10 Jan 2011 13:28:48 +0000 (13:28 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 10 Jan 2011 13:28:48 +0000 (13:28 +0000)
git-svn-id: file:///svn/unbound/trunk@2366 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
util/storage/lruhash.c

index 02b7218fd3ac089633a99562d49a2472fdfeca7c..11120f7021a88b72dc6c3cae7c9fb36e6e03de02 100644 (file)
@@ -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.
index 937a417844c85e125afce3b1aab873ba67c334bb..c22278dda1e85dc7e750a5834155b14745a88068 100644 (file)
@@ -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; i<table->size; 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; i<table->size; 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;