eliminate old locals view path; dont constantly mutate root expressions, simply query locals & build blocks

This commit is contained in:
Ryan Fleury
2024-01-31 10:48:49 -08:00
parent 14db7dbab4
commit 4e9cf2ef89
4 changed files with 60 additions and 141 deletions
+4 -3
View File
@@ -84,7 +84,7 @@ eval_string2num_map_insert(Arena *arena, EVAL_String2NumMap *map, String8 string
U64 hash = eval_hash_from_string(string);
U64 slot_idx = hash%map->slots_count;
EVAL_String2NumMapNode *existing_node = 0;
for(EVAL_String2NumMapNode *node = map->slots[slot_idx].first; node != 0; node = node->next)
for(EVAL_String2NumMapNode *node = map->slots[slot_idx].first; node != 0; node = node->hash_next)
{
if(str8_match(node->string, string, 0) && node->num == num)
{
@@ -95,7 +95,8 @@ eval_string2num_map_insert(Arena *arena, EVAL_String2NumMap *map, String8 string
if(existing_node == 0)
{
EVAL_String2NumMapNode *node = push_array(arena, EVAL_String2NumMapNode, 1);
SLLQueuePush(map->slots[slot_idx].first, map->slots[slot_idx].last, node);
SLLQueuePush_N(map->slots[slot_idx].first, map->slots[slot_idx].last, node, hash_next);
SLLQueuePush_N(map->first, map->last, node, order_next);
node->string = push_str8_copy(arena, string);
node->num = num;
}
@@ -110,7 +111,7 @@ eval_num_from_string(EVAL_String2NumMap *map, String8 string)
U64 hash = eval_hash_from_string(string);
U64 slot_idx = hash%map->slots_count;
EVAL_String2NumMapNode *existing_node = 0;
for(EVAL_String2NumMapNode *node = map->slots[slot_idx].first; node != 0; node = node->next)
for(EVAL_String2NumMapNode *node = map->slots[slot_idx].first; node != 0; node = node->hash_next)
{
if(str8_match(node->string, string, 0))
{
+4 -1
View File
@@ -10,7 +10,8 @@
typedef struct EVAL_String2NumMapNode EVAL_String2NumMapNode;
struct EVAL_String2NumMapNode
{
EVAL_String2NumMapNode *next;
EVAL_String2NumMapNode *order_next;
EVAL_String2NumMapNode *hash_next;
String8 string;
U64 num;
};
@@ -27,6 +28,8 @@ struct EVAL_String2NumMap
{
U64 slots_count;
EVAL_String2NumMapSlot *slots;
EVAL_String2NumMapNode *first;
EVAL_String2NumMapNode *last;
};
////////////////////////////////