Skip to content

chore(spawn-local-jdk): prune glob tree walks in JDKHomeBasedPatternDetector - #56

Merged
deer merged 1 commit into
mainfrom
faster_jdk_detection
Aug 4, 2026
Merged

chore(spawn-local-jdk): prune glob tree walks in JDKHomeBasedPatternDetector#56
deer merged 1 commit into
mainfrom
faster_jdk_detection

Conversation

@deer

@deer deer commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

The glob expansion in JDKHomeBasedPatternDetector previously matched only the full-path glob once a leaf directory was reached, meaning a tree walk had to descend into every directory under the base path even when an early segment could never match. This pulled the giant inline lambda in expandPattern's stream pipeline out into named static methods (expandPattern, isGlobPattern, expandGlobPattern, indexOfBaseEnd) and added a GlobSegments helper plus a PruningGlobVisitor.

GlobSegments splits a glob suffix into its individual path segments (respecting {...}/[...] groups so a separator nested inside one doesn't get sliced apart) and builds a PathMatcher per fixed-depth segment before the first **, if any. PruningGlobVisitor then checks each directory against its corresponding segment matcher as soon as it's visited and returns SKIP_SUBTREE the moment a segment fails to match, rather than walking the whole subtree first. When a {...}/[...] group spans a path separator, the per-segment assumption breaks down, so the code falls back to unpruned full-glob matching for that pattern, exactly as before.

Behavior is otherwise unchanged: plain paths still resolve to themselves without touching the filesystem, non-existent base paths and invalid patterns still yield an empty stream, and FOLLOW_LINKS plus AccessDeniedException handling during the walk are preserved.

@deer
deer merged commit bebb137 into main Aug 4, 2026
1 check passed
@deer
deer deleted the faster_jdk_detection branch August 4, 2026 08:45
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