diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-01-08 12:18:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-08 17:18:42 +0000 |
commit | e212e1fc35ddae63f457f0f2a2e95154e008941f (patch) | |
tree | 6c1f553fbc529bfcab6413049af8f32ed31d1dfd /cli/graph_util.rs | |
parent | ee45d5bf8f2e1826b2a106b030abe891cfc0b37c (diff) |
perf: skip expanding exclude globs (#21817)
We were calling `expand_glob` on our excludes, which is very expensive
and unnecessary because we can pattern match while traversing instead.
1. Doesn't expand "exclude" globs. Instead pattern matches while walking
the directory.
2. Splits up the "include" into base paths and applicable file patterns.
This causes less pattern matching to occur because we're only pattern
matching on patterns that might match and not ones in completely
unrelated directories.
Diffstat (limited to 'cli/graph_util.rs')
-rw-r--r-- | cli/graph_util.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cli/graph_util.rs b/cli/graph_util.rs index 524799860..b4f4b939a 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -16,6 +16,8 @@ use crate::resolver::SloppyImportsResolver; use crate::tools::check; use crate::tools::check::TypeChecker; use crate::util::file_watcher::WatcherCommunicator; +use crate::util::fs::canonicalize_path; +use crate::util::path::specifier_to_file_path; use crate::util::sync::TaskQueue; use crate::util::sync::TaskQueuePermit; @@ -677,7 +679,7 @@ impl ModuleGraphContainer { pub fn has_graph_root_local_dependent_changed( graph: &ModuleGraph, root: &ModuleSpecifier, - changed_specifiers: &HashSet<ModuleSpecifier>, + canonicalized_changed_paths: &HashSet<PathBuf>, ) -> bool { let roots = vec![root.clone()]; let mut dependent_specifiers = graph.walk( @@ -689,11 +691,15 @@ pub fn has_graph_root_local_dependent_changed( }, ); while let Some((s, _)) = dependent_specifiers.next() { - if s.scheme() != "file" { + if let Ok(path) = specifier_to_file_path(s) { + if let Ok(path) = canonicalize_path(&path) { + if canonicalized_changed_paths.contains(&path) { + return true; + } + } + } else { // skip walking this remote module's dependencies dependent_specifiers.skip_previous_dependencies(); - } else if changed_specifiers.contains(s) { - return true; } } false |