From 1afe87571730ba1c42688526abfb2bedcaee607a Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Wed, 8 May 2024 16:10:55 +0800 Subject: [PATCH] Only start offload worker thread when there's more than 1 core --- src/bin/bat/app.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 6fc85321..25720cb2 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -2,6 +2,7 @@ use std::collections::HashSet; use std::env; use std::io::IsTerminal; use std::path::{Path, PathBuf}; +use std::thread::available_parallelism; use crate::{ clap_app, @@ -125,7 +126,9 @@ impl App { // start building glob matchers for builtin mappings immediately // this is an appropriate approach because it's statistically likely that // all the custom mappings need to be checked - syntax_mapping.start_offload_build_all(); + if available_parallelism()?.get() > 1 { + syntax_mapping.start_offload_build_all(); + } if let Some(values) = self.matches.get_many::("ignored-suffix") { for suffix in values {