From 4bc3796f9b9e8ea00ff0da89f6e983345fb2fd7e Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 27 Jul 2021 23:00:51 +0100 Subject: [PATCH] Short circuit `check_with_workers` logic on `worker_count == 0` --- src/checker.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/checker.cpp b/src/checker.cpp index fb4ef5477..649f84c93 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -4078,7 +4078,18 @@ void check_with_workers(Checker *c, gbThreadProc *proc, isize total_count) { worker_count = 0; } - gb_semaphore_post(&c->info.collect_semaphore, cast(i32)worker_count); + gb_semaphore_post(&c->info.collect_semaphore, cast(i32)thread_count); + + if (worker_count == 0) { + ThreadProcCheckerSection section_all = {}; + section_all.checker = c; + section_all.offset = 0; + section_all.count = total_count; + gbThread dummy_main_thread = {}; + dummy_main_thread.user_data = §ion_all; + proc(&dummy_main_thread); + return; + } isize file_load_count = (total_count+thread_count-1)/thread_count; isize remaining_count = total_count; @@ -4713,7 +4724,7 @@ void check_procedure_bodies(Checker *c) { GB_ASSERT(total_queued == original_queue_count); - gb_semaphore_post(&c->procs_to_check_semaphore, cast(i32)worker_count); + gb_semaphore_post(&c->procs_to_check_semaphore, cast(i32)thread_count); gbThread *threads = gb_alloc_array(permanent_allocator(), gbThread, worker_count); for (isize i = 0; i < worker_count; i++) {