rm map_remove;

It's no longer used.
This commit is contained in:
bjorn 2024-03-06 15:08:32 -08:00
parent f9cfc4e76e
commit 9068c8daee
2 changed files with 1 additions and 28 deletions

View File

@ -129,32 +129,6 @@ void map_set(map_t* map, uint64_t hash, uint64_t value) {
map->values[h] = value;
}
void map_remove(map_t* map, uint64_t hash) {
uint64_t h = map_find(map, hash);
if (map->hashes[h] == MAP_NIL) {
return;
}
uint64_t mask = map->size - 1;
uint64_t i = h;
do {
i = (i + 1) & mask;
uint64_t x = map->hashes[i] & mask;
// Removing a key from an open-addressed hash table is complicated
if ((i > h && (x <= h || x > i)) || (i < h && (x <= h && x > i))) {
map->hashes[h] = map->hashes[i];
map->values[h] = map->values[i];
h = i;
}
} while (map->hashes[i] != MAP_NIL);
map->hashes[i] = MAP_NIL;
map->values[i] = MAP_NIL;
map->used--;
}
// UTF-8
// https://github.com/starwing/luautf8
size_t utf8_decode(const char *s, const char *e, unsigned *pch) {

View File

@ -89,7 +89,7 @@ static inline void _arr_reserve(void** data, size_t n, size_t* capacity, size_t
lovrAssert(*data, "Out of memory");
}
// Hashmap
// Hashmap (does not support removal)
typedef struct {
uint64_t* hashes;
uint64_t* values;
@ -103,7 +103,6 @@ void map_init(map_t* map, uint32_t n);
void map_free(map_t* map);
uint64_t map_get(map_t* map, uint64_t hash);
void map_set(map_t* map, uint64_t hash, uint64_t value);
void map_remove(map_t* map, uint64_t hash);
// UTF-8
size_t utf8_decode(const char *s, const char *e, unsigned *pch);