OLD | NEW |
1 /* | 1 /* |
2 * Hash Array Mapped Trie (HAMT) implementation | 2 * Hash Array Mapped Trie (HAMT) implementation |
3 * | 3 * |
4 * Copyright (C) 2001-2007 Peter Johnson | 4 * Copyright (C) 2001-2007 Peter Johnson |
5 * | 5 * |
6 * Based on the paper "Ideal Hash Tries" by Phil Bagwell [2000]. | 6 * Based on the paper "Ideal Hash Tries" by Phil Bagwell [2000]. |
7 * One algorithmic change from that described in the paper: we use the LSB's | 7 * One algorithmic change from that described in the paper: we use the LSB's |
8 * of the key to index the root table and move upward in the key rather than | 8 * of the key to index the root table and move upward in the key rather than |
9 * use the MSBs as described in the paper. The LSBs have more entropy. | 9 * use the MSBs as described in the paper. The LSBs have more entropy. |
10 * | 10 * |
(...skipping 12 matching lines...) Expand all Loading... |
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE | 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE |
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 * POSSIBILITY OF SUCH DAMAGE. | 30 * POSSIBILITY OF SUCH DAMAGE. |
31 */ | 31 */ |
32 #include "util.h" | 32 #include "util.h" |
33 /*@unused@*/ RCSID("$Id: hamt.c 1907 2007-08-05 16:44:07Z peter $"); | |
34 | 33 |
35 #include <ctype.h> | 34 #include <ctype.h> |
36 | 35 |
37 #include "libyasm-stdint.h" | 36 #include "libyasm-stdint.h" |
38 #include "coretype.h" | 37 #include "coretype.h" |
39 #include "hamt.h" | 38 #include "hamt.h" |
40 | 39 |
41 struct HAMTEntry { | 40 struct HAMTEntry { |
42 STAILQ_ENTRY(HAMTEntry) next; /* next hash table entry */ | 41 STAILQ_ENTRY(HAMTEntry) next; /* next hash table entry */ |
43 /*@dependent@*/ const char *str; /* string being hashed */ | 42 /*@dependent@*/ const char *str; /* string being hashed */ |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 /* Count bits below */ | 412 /* Count bits below */ |
414 BitCount(Map, node->BitMapKey & ~((~0UL)<<keypart)); | 413 BitCount(Map, node->BitMapKey & ~((~0UL)<<keypart)); |
415 Map &= 0x1F; /* Clamp to <32 */ | 414 Map &= 0x1F; /* Clamp to <32 */ |
416 | 415 |
417 /* Go down a level */ | 416 /* Go down a level */ |
418 level++; | 417 level++; |
419 node = &(GetSubTrie(node))[Map]; | 418 node = &(GetSubTrie(node))[Map]; |
420 } | 419 } |
421 } | 420 } |
422 | 421 |
OLD | NEW |