mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-16 08:04:07 +00:00
Simplify compiler's Map and create a StringMap specifically for strings
This commit is contained in:
@@ -4310,7 +4310,7 @@ void destroy_ast_file(AstFile *f) {
|
||||
bool init_parser(Parser *p) {
|
||||
GB_ASSERT(p != nullptr);
|
||||
string_set_init(&p->imported_files, heap_allocator());
|
||||
map_init(&p->package_map, heap_allocator());
|
||||
string_map_init(&p->package_map, heap_allocator());
|
||||
array_init(&p->packages, heap_allocator());
|
||||
array_init(&p->package_imports, heap_allocator());
|
||||
gb_mutex_init(&p->file_add_mutex);
|
||||
@@ -4336,7 +4336,7 @@ void destroy_parser(Parser *p) {
|
||||
array_free(&p->packages);
|
||||
array_free(&p->package_imports);
|
||||
string_set_destroy(&p->imported_files);
|
||||
map_destroy(&p->package_map);
|
||||
string_map_destroy(&p->package_map);
|
||||
gb_mutex_destroy(&p->file_add_mutex);
|
||||
gb_mutex_destroy(&p->file_decl_mutex);
|
||||
}
|
||||
@@ -4346,8 +4346,8 @@ void parser_add_package(Parser *p, AstPackage *pkg) {
|
||||
pkg->id = p->packages.count+1;
|
||||
array_add(&p->packages, pkg);
|
||||
if (pkg->name.len > 0) {
|
||||
HashKey key = hash_string(pkg->name);
|
||||
auto found = map_get(&p->package_map, key);
|
||||
StringHashKey key = string_hash_string(pkg->name);
|
||||
auto found = string_map_get(&p->package_map, key);
|
||||
if (found) {
|
||||
GB_ASSERT(pkg->files.count > 0);
|
||||
AstFile *f = pkg->files[0];
|
||||
@@ -4356,7 +4356,7 @@ void parser_add_package(Parser *p, AstPackage *pkg) {
|
||||
TokenPos pos = (*found)->files[0]->package_token.pos;
|
||||
error_line("\tpreviously declared at %.*s(%td:%td)\n", LIT(pos.file), pos.line, pos.column);
|
||||
} else {
|
||||
map_set(&p->package_map, key, pkg);
|
||||
string_map_set(&p->package_map, key, pkg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user