diff options
author | ambrop7 <ambrop7@1a93d707-3861-5ebc-ad3b-9740d49b5140> | 2012-08-02 15:40:18 +0400 |
---|---|---|
committer | ambrop7 <ambrop7@1a93d707-3861-5ebc-ad3b-9740d49b5140> | 2012-08-02 15:40:18 +0400 |
commit | 9923141a742bf3a27b4ed7dd680a7d98cb28bc3e (patch) | |
tree | 6348ccfeb1ada5417e9efd1ee0d599979818153a /structure | |
parent | b58e03f725d5c9bf54b47c91593fe4ec4e009c66 (diff) |
structure: CHash: small optimization in Lookup()
Diffstat (limited to 'structure')
-rw-r--r-- | structure/CHash_impl.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/structure/CHash_impl.h b/structure/CHash_impl.h index d618a27..dadc312 100644 --- a/structure/CHash_impl.h +++ b/structure/CHash_impl.h @@ -160,12 +160,13 @@ static CHashRef CHash_Lookup (const CHash *o, CHashArg arg, CHashKey key) { size_t index = CHASH_PARAM_HASHFUN(arg, key) % o->numBuckets; - CHashRef e = CHash_Deref(arg, o->buckets[index]); - while (e.link != CHashNullLink()) { + CHashLink link = o->buckets[index]; + while (link != CHashNullLink()) { + CHashRef e = CHash_Deref(arg, link); if (CHASH_PARAM_KEYSEQUAL(arg, CHASH_PARAM_GETKEY(arg, e), key)) { return e; } - e = CHash_Deref(arg, e.ptr->CHASH_PARAM_ENTRY_NEXT); + link = e.ptr->CHASH_PARAM_ENTRY_NEXT; } return CHashNullRef(); |