diff options
| author | gingerBill <bill@gingerbill.org> | 2018-01-28 15:37:15 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-01-28 15:37:15 +0000 |
| commit | b66e7bed45702ad54d160c9f59fd19c503357630 (patch) | |
| tree | e6c6b622586c8336bc6f7100d5c94f4bbfb09f33 /src/checker.cpp | |
| parent | e919482aa80ebf4a6a4fe3e1e5a005a7a7c7927c (diff) | |
Improve min-dep for Type Info
Diffstat (limited to 'src/checker.cpp')
| -rw-r--r-- | src/checker.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index 10da68af6..2dec1a7c7 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -576,18 +576,17 @@ void init_universal_scope(void) { void init_checker_info(CheckerInfo *i) { gbAllocator a = heap_allocator(); - map_init(&i->types, a); - array_init(&i->definitions, a); - array_init(&i->entities, a); - map_init(&i->untyped, a); - map_init(&i->foreigns, a); - map_init(&i->gen_procs, a); - map_init(&i->gen_types, a); - map_init(&i->type_info_map, a); - map_init(&i->files, a); + map_init(&i->types, a); + array_init(&i->definitions, a); + array_init(&i->entities, a); + map_init(&i->untyped, a); + map_init(&i->foreigns, a); + map_init(&i->gen_procs, a); + map_init(&i->gen_types, a); + array_init(&i->type_info_types, a); + map_init(&i->type_info_map, a); + map_init(&i->files, a); array_init(&i->variable_init_order, a); - - i->type_info_count = 0; } void destroy_checker_info(CheckerInfo *i) { @@ -598,6 +597,7 @@ void destroy_checker_info(CheckerInfo *i) { map_destroy(&i->foreigns); map_destroy(&i->gen_procs); map_destroy(&i->gen_types); + array_free(&i->type_info_types); map_destroy(&i->type_info_map); map_destroy(&i->files); array_free(&i->variable_init_order); @@ -922,6 +922,7 @@ void add_type_info_type(Checker *c, Type *t) { return; } + bool prev = false; isize ti_index = -1; for_array(i, c->info.type_info_map.entries) { auto *e = &c->info.type_info_map.entries[i]; @@ -929,19 +930,22 @@ void add_type_info_type(Checker *c, Type *t) { if (are_types_identical(t, prev_type)) { // Duplicate entry ti_index = e->value; + prev = true; break; } } if (ti_index < 0) { // Unique entry // NOTE(bill): map entries grow linearly and in order - ti_index = c->info.type_info_count; - c->info.type_info_count++; + ti_index = c->info.type_info_types.count; + array_add(&c->info.type_info_types, t); } map_set(&c->info.type_info_map, hash_type(t), ti_index); - - + if (prev) { + // NOTE(bill): If a previous one exists already, no need to continue + return; + } // Add nested types @@ -3053,7 +3057,8 @@ void check_parsed_files(Checker *c) { // Add "Basic" type information for (isize i = 0; i < gb_count_of(basic_types)-1; i++) { Type *t = &basic_types[i]; - if (t->Basic.size > 0 && t->Basic.kind != Basic_llvm_bool) { + if (t->Basic.size > 0 && + t->Basic.kind != Basic_llvm_bool) { add_type_info_type(c, t); } } @@ -3064,7 +3069,7 @@ void check_parsed_files(Checker *c) { if (e->kind == Entity_TypeName && e->type != nullptr) { // i64 size = type_size_of(c->allocator, e->type); i64 align = type_align_of(c->allocator, e->type); - if (align > 0) { + if (align > 0 && ptr_set_exists(&c->info.minimum_dependency_set, e)) { add_type_info_type(c, e->type); } } |