fuzzy_nucleo: Remove util dependency (#61929)

Release Notes:

- N/A or Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth authored and GitHub committed 2026-07-30 12:59:16 +00:00
1 parent 6576bd2c83
commit e974c3b920
7 files changed
+32 -31

No files matched your search

Generated
+2 -1
View File
@@ -7167,8 +7167,9 @@ dependencies = [
"criterion",
"fuzzy",
"gpui",
"gpui_util",
"nucleo",
"util",
"path",
]
[[package]]
+2 -2
View File
@@ -16,12 +16,12 @@ doctest = false
fuzzy.workspace = true
nucleo.workspace = true
gpui.workspace = true
util.workspace = true
gpui_util.workspace = true
path.workspace = true
[dev-dependencies]
criterion.workspace = true
gpui = { workspace = true, features = ["test-support"] }
util = { workspace = true, features = ["test-support"] }
[[bench]]
name = "match_benchmark"
@@ -1,7 +1,7 @@
use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group, criterion_main};
use fuzzy::CharBag;
use path::{PathStyle, rel_path::RelPath};
use std::sync::atomic::AtomicBool;
use util::{paths::PathStyle, rel_path::RelPath};
const DIRS: &[&str] = &[
"src",
+3 -3
View File
@@ -1,4 +1,5 @@
use gpui::BackgroundExecutor;
use path::{PathStyle, rel_path::RelPath};
use std::{
cmp::Ordering,
sync::{
@@ -6,7 +7,6 @@ use std::{
atomic::{self, AtomicBool},
},
};
use util::{paths::PathStyle, rel_path::RelPath};
use nucleo::Utf32Str;
use nucleo::pattern::Pattern;
@@ -256,7 +256,7 @@ pub fn match_fixed_path_set(
&AtomicBool::new(false),
)
.ok();
util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
gpui_util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
matcher::return_matcher(matcher);
results
}
@@ -351,6 +351,6 @@ pub async fn match_path_sets<'a, Set: PathMatchCandidateSet<'a>>(
}
let mut results = segment_results.concat();
util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
gpui_util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
results
}
+2 -2
View File
@@ -161,7 +161,7 @@ where
}
let mut results = segment_results.concat();
util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
gpui_util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
results
}
@@ -198,7 +198,7 @@ where
.ok();
matcher::return_matcher(matcher);
util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
gpui_util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
results
}
+22
View File
@@ -578,3 +578,25 @@ fn type_id_hasher() {
verify_hashing_with(TypeId::of::<&str>());
verify_hashing_with(TypeId::of::<Vec<u8>>());
}
pub fn truncate_to_bottom_n_sorted_by<T, F>(items: &mut Vec<T>, limit: usize, compare: &F)
where
F: Fn(&T, &T) -> std::cmp::Ordering,
{
if limit == 0 {
items.truncate(0);
}
if items.len() <= limit {
items.sort_by(compare);
return;
}
// When limit is near to items.len() it may be more efficient to sort the whole list and
// truncate, rather than always doing selection first as is done below. It's hard to analyze
// where the threshold for this should be since the quickselect style algorithm used by
// `select_nth_unstable_by` makes the prefix partially sorted, and so its work is not wasted -
// the expected number of comparisons needed by `sort_by` is less than it is for some arbitrary
// unsorted input.
items.select_nth_unstable_by(limit, compare);
items.truncate(limit);
items.sort_by(compare);
}
-22
View File
@@ -210,28 +210,6 @@ where
}
}
pub fn truncate_to_bottom_n_sorted_by<T, F>(items: &mut Vec<T>, limit: usize, compare: &F)
where
F: Fn(&T, &T) -> Ordering,
{
if limit == 0 {
items.truncate(0);
}
if items.len() <= limit {
items.sort_by(compare);
return;
}
// When limit is near to items.len() it may be more efficient to sort the whole list and
// truncate, rather than always doing selection first as is done below. It's hard to analyze
// where the threshold for this should be since the quickselect style algorithm used by
// `select_nth_unstable_by` makes the prefix partially sorted, and so its work is not wasted -
// the expected number of comparisons needed by `sort_by` is less than it is for some arbitrary
// unsorted input.
items.select_nth_unstable_by(limit, compare);
items.truncate(limit);
items.sort_by(compare);
}
/// Prevents execution of the application with root privileges on Unix systems.
///
/// This function checks if the current process is running with root privileges