Skip to content

Commit

Permalink
Remove duplicates in -defineables
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed Nov 8, 2024
1 parent e03f998 commit 20a8c97
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1789,8 +1789,22 @@ gb_internal GB_COMPARE_PROC(defineables_cmp) {
return i32_cmp(x->pos.offset, y->pos.offset);
}

gb_internal void sort_defineables(Checker *c) {
gb_internal void sort_defineables_and_remove_duplicates(Checker *c) {
if (c->info.defineables.count == 0) {
return;
}
gb_sort_array(c->info.defineables.data, c->info.defineables.count, defineables_cmp);

Defineable prev = c->info.defineables[0];
for (isize i = 1; i < c->info.defineables.count; ) {
Defineable curr = c->info.defineables[i];
if (prev.pos == curr.pos) {
array_ordered_remove(&c->info.defineables, i);
continue;
}
prev = curr;
i++;
}
}

gb_internal void export_defineables(Checker *c, String path) {
Expand Down Expand Up @@ -3451,7 +3465,7 @@ int main(int arg_count, char const **arg_ptr) {
if (build_context.show_defineables || build_context.export_defineables_file != "") {
TEMPORARY_ALLOCATOR_GUARD();
temp_alloc_defineable_strings(checker);
sort_defineables(checker);
sort_defineables_and_remove_duplicates(checker);

if (build_context.show_defineables) {
show_defineables(checker);
Expand Down

0 comments on commit 20a8c97

Please sign in to comment.