diff options
Diffstat (limited to 'erts/emulator/beam/hash.h')
-rw-r--r-- | erts/emulator/beam/hash.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/erts/emulator/beam/hash.h b/erts/emulator/beam/hash.h index cbd75f3025..4e8eb6594b 100644 --- a/erts/emulator/beam/hash.h +++ b/erts/emulator/beam/hash.h @@ -99,6 +99,7 @@ void* hash_remove(Hash*, void*); void hash_foreach(Hash*, HFOREACH_FUN, void *); ERTS_GLB_INLINE Uint hash_get_slot(Hash *h, HashValue hv); +ERTS_GLB_INLINE void* hash_fetch(Hash *, void*, H_FUN, HCMP_FUN); #if ERTS_GLB_INLINE_INCL_FUNC_DEF @@ -127,6 +128,22 @@ hash_get_slot(Hash *h, HashValue hv) #endif } +ERTS_GLB_INLINE void* hash_fetch(Hash *h, void* tmpl, H_FUN hash, HCMP_FUN cmp) +{ + HashValue hval = hash(tmpl); + Uint ix = hash_get_slot(h, hval); + HashBucket* b = h->bucket[ix]; + ASSERT(h->fun.hash == hash); + ASSERT(h->fun.cmp == cmp); + + while(b != (HashBucket*) 0) { + if ((b->hvalue == hval) && (cmp(tmpl, (void*)b) == 0)) + return (void*) b; + b = b->next; + } + return (void*) 0; +} + #endif /* ERTS_GLB_INLINE_INCL_FUNC_DEF */ #endif |