Repository navigation
perf: list directories instead of looking up each CLI path - #1483
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1482. Most of the remaining time spent on a file path provided on the command line was statting and canonicalizing it.
When at least 8 of the paths are in the same directory, that directory is now canonicalized and listed once instead. A name listed as a regular file is not a symlink, and matching the listed name exactly means there is no casing difference to resolve, so neither call is necessary for it. Everything else (ex. directories, symlinks, casing differences, long paths) is looked up as before.
Listing a directory stops after 4 entries for each of the paths in it and then falls back to looking up each path. A test with 500 paths in a directory with 20,000 other files took 24.5ms instead of 23.6ms on Windows because of that.
dprint checkwith 500 file paths:This also replaces
dir_infoon the environment withsys_traits'FsReadDir, so there's one way to list a directory and code can iterate the entries without collecting them.