diff options
| author | gingerBill <bill@gingerbill.org> | 2024-11-08 11:24:00 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-11-08 11:24:00 +0000 |
| commit | 20a8c97d68e7878fc7253d6af3a6a9bb6246c150 (patch) | |
| tree | 76fd3052c6b2dc72375bedbc93546d25ca79f55e /src/main.cpp | |
| parent | e03f998c270fbc76f59ca842c94c8830e906ecd1 (diff) | |
Remove duplicates in `-defineables`
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index 92d03b47a..3a32639b8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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) { @@ -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); |