[dotfiles-improvement] perf: replace find-subshell dir-checks with ZSH glob in git-utils.zsh - #530
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
Replace 6 occurrences of find-based existence checks that spawn
subshells with ZSH-native glob qualifier pattern (no subshell):
Before: if [[ -z "$(find . -type d -maxdepth 1 -name "$pat" -print -quit)" ]]
After: local -a _match_dirs=( ./${~pat}(N/) )
if (( ${#_match_dirs} == 0 ))
The (N/) glob qualifier means N=nullglob (no error if no match),
/=directories only. Consistent with noglob aliases already in place.
Affected: go-mod-upgrade-dirs, exec-dirs, exec-dirs-ds,
exec-dirs-ds-echo, code-dirs, finder-dirs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions Bot
added a commit
that referenced
this pull request
Aug 6, 2026
Replace two find subprocess forks in view-pr-dirs (util.zsh) with
ZSH-native glob qualifying and an explicit for loop:
- $(find . -type d -maxdepth 1 -name "$1" -print -quit) -> .${~1}(N/)
(nullglob + dir-only qualifier, no subshell)
- find -exec sh -c '...' -> explicit for _dir in ... loop with subshell
(eliminates one find fork and one sh fork per directory)
Consistent with the same improvement in git-utils.zsh (PR #530).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
What
Six functions in
zsh/functions/git-utils.zshuse a subshell$(find ...)call just to check if any directories matching a glob pattern exist before proceeding:Change
Replace with ZSH-native glob qualifier
(N/)— no subshell, no fork:(N/)= nullglob (no error if no match) + only match directories${~1}= expand$1as a glob pattern (e.g.velero*stays a glob)noglobaliases already defined at the bottom of the fileAffected functions (6 occurrences)
go-mod-upgrade-dirsexec-dirsexec-dirs-dsexec-dirs-ds-echocode-dirsfinder-dirsNo behavior change
Semantically equivalent to the
find -print -quitcheck. Thenoglobaliases that call these functions already pass raw glob patterns (e.g.velero*), which${~var}handles correctly.