aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-11-01 20:54:04 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-11-01 20:54:04 +0100
commit92669e1c9f16fa3050e7e27a0f3cafc45b5a156f (patch)
tree5ee759b88a14f8f287a3497d77a48fd5d60b1063 /src
parent0eb238cf006caac8f7b19a85426905d388f6a20a (diff)
Don’t spawn threads for 1 file or 1 CPU
Diffstat (limited to 'src')
-rw-r--r--src/tpool.c2
1 files changed, 2 insertions, 0 deletions
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)