diff options
author | Bad Diode <bd@badd10de.dev> | 2021-10-21 18:23:18 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-10-21 18:23:18 +0200 |
commit | 2625019add3d16d3ee5d210bcebdd999d3b0cc32 (patch) | |
tree | 5c53af4f92ed4e924d4817cccfd834e81354c150 /src/bootstrap/hashtable.h | |
parent | 61f617fe39f891f3dfc5b4815e20ef70a0497a64 (diff) | |
download | bdl-2625019add3d16d3ee5d210bcebdd999d3b0cc32.tar.gz bdl-2625019add3d16d3ee5d210bcebdd999d3b0cc32.zip |
Change environments to be a hash tablev0.7
Diffstat (limited to 'src/bootstrap/hashtable.h')
-rw-r--r-- | src/bootstrap/hashtable.h | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/src/bootstrap/hashtable.h b/src/bootstrap/hashtable.h index ca4ced8..ea24d04 100644 --- a/src/bootstrap/hashtable.h +++ b/src/bootstrap/hashtable.h | |||
@@ -35,7 +35,6 @@ _xor_shift_hash(const char *key, size_t n) { | |||
35 | uint64_t hash = 0x65d9d65f6a19574f; | 35 | uint64_t hash = 0x65d9d65f6a19574f; |
36 | char *last = (char *)key + n; | 36 | char *last = (char *)key + n; |
37 | while (key != last) { | 37 | while (key != last) { |
38 | putchar(*key); | ||
39 | hash ^= (uint64_t)*key++; | 38 | hash ^= (uint64_t)*key++; |
40 | hash = (hash << 8) | (hash >> (64 - 8)); | 39 | hash = (hash << 8) | (hash >> (64 - 8)); |
41 | } | 40 | } |
@@ -50,7 +49,7 @@ _fibonacci_hash(uint64_t hash, size_t shift_amount) { | |||
50 | 49 | ||
51 | uint64_t | 50 | uint64_t |
52 | ht_hash(const HashTable *table, const Object *key) { | 51 | ht_hash(const HashTable *table, const Object *key) { |
53 | uint64_t hash; | 52 | uint64_t hash = 0; |
54 | switch (key->type) { | 53 | switch (key->type) { |
55 | case OBJ_TYPE_FIXNUM: { | 54 | case OBJ_TYPE_FIXNUM: { |
56 | hash = key->fixnum; | 55 | hash = key->fixnum; |
@@ -178,23 +177,6 @@ ht_lookup(const HashTable *table, const Object *key) { | |||
178 | } | 177 | } |
179 | 178 | ||
180 | void | 179 | void |
181 | ht_debug(HashTable *table) { | ||
182 | HashTablePair *pairs = table->pairs; | ||
183 | for (size_t i = 0; i < array_cap(pairs); i++) { | ||
184 | printf("i: %ld ", i); | ||
185 | if (pairs[i].key == NULL) { | ||
186 | printf("EMPTY\n"); | ||
187 | } else { | ||
188 | printf("key: "); | ||
189 | display(pairs[i].key); | ||
190 | printf(" value: "); | ||
191 | display(pairs[i].value); | ||
192 | printf("\n"); | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | |||
197 | void | ||
198 | ht_free(HashTable *table) { | 180 | ht_free(HashTable *table) { |
199 | if (table == NULL) { | 181 | if (table == NULL) { |
200 | return; | 182 | return; |