util: Use GlobSet in PathMatcher (#13197)
Previously we were using a single globset::Glob in PathMatcher; higher
up the stack, we were then resorting to using a list of PathMatchers.
globset crate exposes a GlobSet type that's better suited for this use
case. In my benchmarks, using a single PathMatcher with GlobSet instead
of a Vec of PathMatchers with Globs is about 3 times faster with the
default 'file_scan_exclusions' values. This slightly improves our
project load time for projects with large # of files, as showcased in
the following videos of loading a project with 100k source files. This
project is *not* a git repository, so it should measure raw overhead on
our side.
Current nightly: 51404d4ea0
https://github.com/zed-industries/zed/assets/24362066/e0aa9f8c-aae6-4348-8d42-d20bd41fcd76
versus this PR:
https://github.com/zed-industries/zed/assets/24362066/408dcab1-cee2-4c9e-a541-a31d14772dd7
Release Notes:
- Improved performance in large worktrees
This commit is contained in:
parent
64d815a176
commit
5dc26c261d
13 changed files with 193 additions and 187 deletions
|
@ -927,8 +927,8 @@ impl BufferSearchBar {
|
|||
self.search_options.contains(SearchOptions::WHOLE_WORD),
|
||||
self.search_options.contains(SearchOptions::CASE_SENSITIVE),
|
||||
false,
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
) {
|
||||
Ok(query) => query.with_replacement(self.replacement(cx)),
|
||||
Err(_) => {
|
||||
|
@ -944,8 +944,8 @@ impl BufferSearchBar {
|
|||
self.search_options.contains(SearchOptions::WHOLE_WORD),
|
||||
self.search_options.contains(SearchOptions::CASE_SENSITIVE),
|
||||
false,
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
) {
|
||||
Ok(query) => query.with_replacement(self.replacement(cx)),
|
||||
Err(_) => {
|
||||
|
|
|
@ -3,7 +3,6 @@ use crate::{
|
|||
SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive, ToggleIncludeIgnored, ToggleRegex,
|
||||
ToggleReplace, ToggleWholeWord,
|
||||
};
|
||||
use anyhow::Context as _;
|
||||
use collections::{HashMap, HashSet};
|
||||
use editor::{
|
||||
actions::SelectAll,
|
||||
|
@ -876,7 +875,7 @@ impl ProjectSearchView {
|
|||
if should_mark_error {
|
||||
cx.notify();
|
||||
}
|
||||
vec![]
|
||||
PathMatcher::default()
|
||||
}
|
||||
};
|
||||
let excluded_files =
|
||||
|
@ -894,7 +893,7 @@ impl ProjectSearchView {
|
|||
if should_mark_error {
|
||||
cx.notify();
|
||||
}
|
||||
vec![]
|
||||
PathMatcher::default()
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -960,15 +959,14 @@ impl ProjectSearchView {
|
|||
query
|
||||
}
|
||||
|
||||
fn parse_path_matches(text: &str) -> anyhow::Result<Vec<PathMatcher>> {
|
||||
text.split(',')
|
||||
fn parse_path_matches(text: &str) -> anyhow::Result<PathMatcher> {
|
||||
let queries = text
|
||||
.split(',')
|
||||
.map(str::trim)
|
||||
.filter(|maybe_glob_str| !maybe_glob_str.is_empty())
|
||||
.map(|maybe_glob_str| {
|
||||
PathMatcher::new(maybe_glob_str)
|
||||
.with_context(|| format!("parsing {maybe_glob_str} as path matcher"))
|
||||
})
|
||||
.collect()
|
||||
.map(str::to_owned)
|
||||
.collect::<Vec<_>>();
|
||||
Ok(PathMatcher::new(&queries)?)
|
||||
}
|
||||
|
||||
fn select_match(&mut self, direction: Direction, cx: &mut ViewContext<Self>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue