Repository navigation
refactor(core): build ancestor dirs incrementally during scan - #63453
delaysystem wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
The search change is sound. The new loop builds exactly the same ancestor directory keys as the old slice().join("/") loop: I checked both against edge-case paths (empty, leading /, //, ./, trailing /) and they matched. The focused search tests and the tsc type check for packages/core pass.
Public API: unchanged.
- The branch also includes
b8e5960e5, the Swift highlights pin from your #63165 (see inline). Please drop it here so each change is reviewed and merged once. - The new nested-directory test passes on the base too, since the refactor keeps behaviour the same. It can be dropped to keep this minimal.
| // NOTE: Using parser repo queries instead of nvim-treesitter due to incompatible #lua-match? predicates | ||
| // "https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/refs/heads/master/queries/highlights.scm | ||
| "https://raw.githubusercontent.com/alex-pinkus/tree-sitter-swift/main/queries/highlights.scm", | ||
| "https://raw.githubusercontent.com/alex-pinkus/tree-sitter-swift/0.7.1/queries/highlights.scm", |
Replace the O(depth^2) slice+join per file with a single incremental prefix pass producing identical strings. Adds a nested-dirs test.
85f8519 to
a319bf0
Compare
There was a problem hiding this comment.
The Swift highlights commit is gone and the branch is rebased onto the latest dev, so it now changes only the search refactor. The ancestor-directory loop is unchanged from the version I checked before (same keys as the old slice().join() loop). The focused search tests and the tsc type check for packages/core pass.
Public API: unchanged.
No new concerns. The new nested-directory test also passes on the base, so it can still be dropped to keep the change minimal.
Issue for this PR
N/A — small performance refactor, no behavior change.
Type of change
What does this PR do?
While scanning, each file rebuilt every ancestor directory string with
parts.slice(0, offset + 1).join("/")— O(depth²) slicing per file. This builds the same strings with a single incremental prefix pass, producing identical directory entries. Adds a test covering nested directory indexing.Note: this touches
packages/core/src/filesystem/search.tsin a hunk disjoint from the sibling PR fromopt/find-index-cache. They are sequenced — if this one lands first, the other branch will rebase.How did you verify your code works?
Ran the focused suite in
packages/core:Checklist