summaryrefslogtreecommitdiff
path: root/assoc.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2011-10-02 01:23:46 -0700
committerdormando <dormando@rydia.net>2011-11-09 16:06:08 -0800
commitbab9acd115828e44176a3671bd65089d6fdeff85 (patch)
tree9230ad6621ab3bed65778000730c2c162cb72ca7 /assoc.c
parent45e0e9500f11783e227898c7af66a4b5c0057f41 (diff)
downloadmemcached-bab9acd115828e44176a3671bd65089d6fdeff85.tar.gz
move hash calls outside of cache_lock
been hard to measure while using the intel hash (since it's very fast), but should help with the software hash.
Diffstat (limited to 'assoc.c')
-rw-r--r--assoc.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/assoc.c b/assoc.c
index 59cbb0f..3530a62 100644
--- a/assoc.c
+++ b/assoc.c
@@ -73,8 +73,7 @@ void assoc_init(const int hashtable_init) {
STATS_UNLOCK();
}
-item *assoc_find(const char *key, const size_t nkey) {
- uint32_t hv = hash(key, nkey, 0);
+item *assoc_find(const char *key, const size_t nkey, const uint32_t hv) {
item *it;
unsigned int oldbucket;
@@ -103,8 +102,7 @@ item *assoc_find(const char *key, const size_t nkey) {
/* returns the address of the item pointer before the key. if *item == 0,
the item wasn't found */
-static item** _hashitem_before (const char *key, const size_t nkey) {
- uint32_t hv = hash(key, nkey, 0);
+static item** _hashitem_before (const char *key, const size_t nkey, const uint32_t hv) {
item **pos;
unsigned int oldbucket;
@@ -146,13 +144,11 @@ static void assoc_expand(void) {
}
/* Note: this isn't an assoc_update. The key must not already exist to call this */
-int assoc_insert(item *it) {
- uint32_t hv;
+int assoc_insert(item *it, const uint32_t hv) {
unsigned int oldbucket;
- assert(assoc_find(ITEM_key(it), it->nkey) == 0); /* shouldn't have duplicately named things defined */
+// assert(assoc_find(ITEM_key(it), it->nkey) == 0); /* shouldn't have duplicately named things defined */
- hv = hash(ITEM_key(it), it->nkey, 0);
if (expanding &&
(oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket)
{
@@ -172,8 +168,8 @@ int assoc_insert(item *it) {
return 1;
}
-void assoc_delete(const char *key, const size_t nkey) {
- item **before = _hashitem_before(key, nkey);
+void assoc_delete(const char *key, const size_t nkey, const uint32_t hv) {
+ item **before = _hashitem_before(key, nkey, hv);
if (*before) {
item *nxt;