summaryrefslogtreecommitdiff
path: root/main/astobj2.c
diff options
context:
space:
mode:
authorStefan Schmidt <sst@sil.at>2011-05-05 07:09:20 +0000
committerStefan Schmidt <sst@sil.at>2011-05-05 07:09:20 +0000
commit19eb6c738462b29fba27011c34caac9ee3e7b5ee (patch)
tree26707a1701d13d7b072597c5870cfc029fd8b904 /main/astobj2.c
parentfe5938c51e973b8e29007f57801e73fa466f0b1d (diff)
Adding the Move to Front Hash functionality
Moving a found object to the front of its bucket to reduce the necessary traversal steps to find an object. This change improves the search time on large system with many data or in link lists. (closes issue #19233) Reported by: schmidts Review: https://reviewboard.asterisk.org/r/1201/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@316962 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/astobj2.c')
-rw-r--r--main/astobj2.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/main/astobj2.c b/main/astobj2.c
index 5e61d5e5f..5f4cda91e 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -734,6 +734,10 @@ static void *internal_ao2_callback(struct ao2_container *c,
}
ast_free(cur); /* free the link record */
}
+ if ((match) && (!(flags & OBJ_UNLINK))) {
+ AST_LIST_REMOVE_CURRENT(entry);
+ AST_LIST_INSERT_HEAD(&c->buckets[i], cur, entry);
+ }
if ((match & CMP_STOP) || !(flags & OBJ_MULTIPLE)) {
/* We found our only (or last) match, so force an exit from