From 92669e1c9f16fa3050e7e27a0f3cafc45b5a156f Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 1 Nov 2024 20:54:04 +0100 Subject: Don’t spawn threads for 1 file or 1 CPU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tpool.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tpool.c b/src/tpool.c index 3e8a0de..739607e 100644 --- a/src/tpool.c +++ b/src/tpool.c @@ -45,6 +45,8 @@ tpinit(tpool_t *tp, const char **files, ptrdiff_t filecnt) tp->tcnt = MIN(tp->tcnt, filecnt); tp->wi = 0; + if (tp->tcnt == 1) + return 0; /* Initiate single-threaded behaviour */ if (tp->tcnt <= 32) tp->thrds = thread_buffer; else if ((tp->thrds = malloc(sizeof(*tp->thrds) * tp->tcnt)) == nullptr) -- cgit v1.2.3