clean up HashTable, removed unused command line switches, added

list wrapper for alt names, added natvis for HashTable, AltNameList,
MergeDirectiveList, and IncludeSymbolList
This commit is contained in:
Nikita Smith
2025-09-05 15:19:31 -07:00
committed by Ryan Fleury
parent 6a3d7e65f3
commit 56c43ad614
10 changed files with 178 additions and 214 deletions
+57 -68
View File
@@ -24,17 +24,10 @@ bucket_list_pop(BucketList *list)
return result;
}
////////////////////////////////
#define XXH_STATIC_LINKING_ONLY
#include "third_party/xxHash/xxhash.c"
#include "third_party/xxHash/xxhash.h"
internal U64
hash_table_hasher(String8 string)
{
XXH64_hash_t hash64 = XXH3_64bits(string.str, string.size);
return hash64;
return u64_hash_from_str8(string);
}
internal HashTable *
@@ -211,6 +204,18 @@ hash_table_search_u64(HashTable *ht, U64 key_u64)
return 0;
}
internal KeyValuePair *
hash_table_search_path(HashTable *ht, String8 path)
{
Temp scratch = scratch_begin(0,0);
String8 path_canon = path;
path_canon = lower_from_str8(scratch.arena, path_canon);
path_canon = path_convert_slashes(scratch.arena, path_canon, PathStyle_UnixAbsolute);
KeyValuePair *result = hash_table_search_string(ht, path_canon);
scratch_end(scratch);
return result;
}
internal KeyValuePair *
hash_table_search_raw(HashTable *ht, void *key)
{
@@ -225,18 +230,6 @@ hash_table_search_raw(HashTable *ht, void *key)
return 0;
}
internal KeyValuePair *
hash_table_search_path(HashTable *ht, String8 path)
{
Temp scratch = scratch_begin(0,0);
String8 path_canon = path;
path_canon = lower_from_str8(scratch.arena, path_canon);
path_canon = path_convert_slashes(scratch.arena, path_canon, PathStyle_UnixAbsolute);
KeyValuePair *result = hash_table_search_string(ht, path_canon);
scratch_end(scratch);
return result;
}
internal B32
hash_table_search_path_u64(HashTable *ht, String8 key, U64 *value_out)
{
@@ -250,53 +243,6 @@ hash_table_search_path_u64(HashTable *ht, String8 key, U64 *value_out)
return 0;
}
internal void *
hash_table_search_u64_raw(HashTable *ht, U64 key_u64)
{
KeyValuePair *kv = hash_table_search_u64(ht, key_u64);
return kv ? kv->value_raw : 0;
}
internal void *
hash_table_search_path_raw(HashTable *ht, String8 path)
{
KeyValuePair *kv = hash_table_search_path(ht, path);
return kv ? kv->value_raw : 0;
}
internal void *
hash_table_search_raw_raw(HashTable *ht, void *key)
{
KeyValuePair *kv = hash_table_search_raw(ht, key);
return kv ? kv->value_raw : 0;
}
internal B32
hash_table_search_string_u64(HashTable *ht, String8 key, U64 *value_out)
{
KeyValuePair *result = hash_table_search_string(ht, key);
if (result != 0) {
if (value_out != 0) {
*value_out = result->value_u64;
}
return 1;
}
return 0;
}
internal B32
hash_table_search_string_raw(HashTable *ht, String8 key, void *value_out)
{
KeyValuePair *result = hash_table_search_string(ht, key);
if (result) {
if (value_out) {
(*(void **)value_out) = result->value_raw;
}
return 1;
}
return 0;
}
internal BucketNode *
hash_table_push_u32_u32(Arena *arena, HashTable *ht, U32 key, U32 value)
{
@@ -311,6 +257,19 @@ hash_table_push_raw_raw(Arena *arena, HashTable *ht, void *key, void *value)
return hash_table_push(arena, ht, hash, (KeyValuePair){ .key_raw = key, .value_raw = value });
}
internal B32
hash_table_search_string_u64(HashTable *ht, String8 key, U64 *value_out)
{
KeyValuePair *result = hash_table_search_string(ht, key);
if (result != 0) {
if (value_out != 0) {
*value_out = result->value_u64;
}
return 1;
}
return 0;
}
internal B32
hash_table_search_string_string(HashTable *ht, String8 key, String8 *value_out)
{
@@ -337,7 +296,36 @@ hash_table_search_u32_u32(HashTable *ht, U32 key, U32 *value_out)
return 0;
}
////////////////////////////////
internal void *
hash_table_search_string_raw(HashTable *ht, String8 key)
{
KeyValuePair *result = hash_table_search_string(ht, key);
if (result) {
return result->value_raw;
}
return 0;
}
internal void *
hash_table_search_u64_raw(HashTable *ht, U64 key_u64)
{
KeyValuePair *kv = hash_table_search_u64(ht, key_u64);
return kv ? kv->value_raw : 0;
}
internal void *
hash_table_search_path_raw(HashTable *ht, String8 path)
{
KeyValuePair *kv = hash_table_search_path(ht, path);
return kv ? kv->value_raw : 0;
}
internal void *
hash_table_search_raw_raw(HashTable *ht, void *key)
{
KeyValuePair *kv = hash_table_search_raw(ht, key);
return kv ? kv->value_raw : 0;
}
internal int
key_value_pair_is_before_u32(void *a, void *b)
@@ -434,6 +422,7 @@ values_from_hash_table_raw(Arena *arena, HashTable *ht)
}
return result;
}
#include "third_party/radsort/radsort.h"
internal void