aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschmidts <schmidts@f38db490-d61c-443f-a65b-d21fe96a405b>2011-05-05 07:09:20 +0000
committerschmidts <schmidts@f38db490-d61c-443f-a65b-d21fe96a405b>2011-05-05 07:09:20 +0000
commitb21d3527ad7ef450e3909c090111c5ff24ac7cfa (patch)
tree26707a1701d13d7b072597c5870cfc029fd8b904
parent75252c5ccf0ab8f883ce7883d4fa4857d467b807 (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: http://svn.digium.com/svn/asterisk/trunk@316962 f38db490-d61c-443f-a65b-d21fe96a405b
-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