aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-04-13 13:02:30 +0100
committergingerBill <bill@gingerbill.org>2020-04-13 13:02:30 +0100
commitf09b6a4c90805a562b2252430f844e85d06f1ee1 (patch)
tree39555c6b9503685c71fd969034ddd5614bfdc357 /src/check_expr.cpp
parent65a2125dba5652577588afee31d7333f13eb0c31 (diff)
Simplify compiler's `Map` and create a `StringMap` specifically for strings
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 12712443f..e446752a1 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -1065,8 +1065,6 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ
}
}
- HashKey key = hash_string(e->token.string);
-
if (e->kind == Entity_ProcGroup) {
auto *pge = &e->ProcGroup;
@@ -6421,9 +6419,9 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
// NOTE(bill): This is give type hints for the named parameters
// in order to improve the type inference system
- Map<Type *> type_hint_map = {}; // Key: String
- map_init(&type_hint_map, heap_allocator(), 2*ce->args.count);
- defer (map_destroy(&type_hint_map));
+ StringMap<Type *> type_hint_map = {}; // Key: String
+ string_map_init(&type_hint_map, heap_allocator(), 2*ce->args.count);
+ defer (string_map_destroy(&type_hint_map));
Type *ptype = nullptr;
bool single_case = true;
@@ -6453,7 +6451,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
if (is_blank_ident(e->token)) {
continue;
}
- map_set(&type_hint_map, hash_string(e->token.string), e->type);
+ string_map_set(&type_hint_map, e->token.string, e->type);
}
}
}
@@ -6475,8 +6473,8 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
if (is_blank_ident(e->token)) {
continue;
}
- HashKey key = hash_string(e->token.string);
- Type **found = map_get(&type_hint_map, key);
+ StringHashKey key = string_hash_string(e->token.string);
+ Type **found = string_map_get(&type_hint_map, key);
if (found) {
Type *t = *found;
if (t == nullptr) {
@@ -6487,10 +6485,10 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
// NOTE(bill): No need to set again
} else {
// NOTE(bill): Ambiguous named parameter across all types so set it to a nullptr
- map_set(&type_hint_map, key, cast(Type *)nullptr);
+ string_map_set(&type_hint_map, key, cast(Type *)nullptr);
}
} else {
- map_set(&type_hint_map, key, e->type);
+ string_map_set(&type_hint_map, key, e->type);
}
}
}
@@ -6508,7 +6506,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
if (field != nullptr && field->kind == Ast_Ident) {
String key = field->Ident.token.string;
- Type **found = map_get(&type_hint_map, hash_string(key));
+ Type **found = string_map_get(&type_hint_map, key);
if (found) {
type_hint = *found;
}