Skip to content

Commit

Permalink
Only start offload worker thread when there's more than 1 core
Browse files Browse the repository at this point in the history
  • Loading branch information
cyqsimon committed May 8, 2024
1 parent b4e3a84 commit 1afe875
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/bin/bat/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<String>("ignored-suffix") {
for suffix in values {
Expand Down

0 comments on commit 1afe875

Please sign in to comment.