Skip to content

perf: skip matching globs for files whose name cannot match when globbing - #1484

Merged
dsherret merged 1 commit into
mainfrom
perf/glob-file-name-filter
Nov 29, 2026
Merged

dsherret merged 1 commit into
mainfrom
perf/glob-file-name-filter

Conversation

@dsherret

Copy link
Copy Markdown
Member

When globbing, files whose name can't match the config's includes are now rejected based on their name before matching any globs. What a name may be comes from the last component of each include (ex. **/*.{ts,tsx} or **/Cargo.lock), which covers the includes derived from the plugins and simple ones in a config file.

It only skips files that the globs would not match either. If any include is too complex to be sure about (ex. src/** or **/*.[jt]s), then it's not used. A test verifies this by checking that a rejected file never matches for every pair of a list of patterns.

dprint output-file-paths with the TypeScript plugin:

Before After
Linux, TypeScript 90.7ms 75.2ms
Linux, Deno 127.8ms 112.3ms
Linux, DefinitelyTyped 62.6ms 61.9ms
macOS, TypeScript 134.0ms 122.2ms
macOS, Deno 127.5ms 126.8ms
macOS, DefinitelyTyped 192.0ms 192.8ms
Windows, Deno 311.7ms 309.0ms
Windows, DefinitelyTyped 190.0ms 188.5ms

It helps when matching globs is a large part of the time and many files don't match. Otherwise there's little to no difference.

@dsherret
dsherret merged commit 9443616 into main Nov 29, 2026
6 checks passed
@dsherret
dsherret deleted the perf/glob-file-name-filter branch November 29, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant