-
-
Save corsix/65ffbd66bbd199b3d77e4ec24c3d3724 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uint64_t table_lookup(hash_table_t* table, uint32_t key) { | |
| uint64_t mask = table->mask; | |
| uint64_t* slots = table->slots; | |
| for (uint64_t d = 0;; ++d) { | |
| uint64_t idx = (int32_t)(key + d) & mask; | |
| uint64_t slot = slots[idx]; | |
| if (slot == 0) { | |
| return 0; | |
| } else if (key == (uint32_t)slot) { | |
| return (slot >> 32) | (slot << 32); | |
| } else if (((idx - slot) & mask) < d) { | |
| return 0; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment