[dotfiles-improvement] perf: replace find+sh-c exec loop with ZSH glob in view-pr-dirs (util.zsh) - #558
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
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.
Replace two
findsubprocess forks inview-pr-dirs(util.zsh) with ZSH-native glob qualifying and an explicit for loop.What
view-pr-dirsused two separatefindinvocations:Why
(N/)= nullglob (no error if no match) + directory-only qualifier — ZSH built-in, no subprocess${~1}= expand$1as a glob pattern (safe with the existingnoglobalias)findfork for the guard check and 1find+ 1shfork per matched directoryFiles Modified
zsh/util.zsh:view-pr-dirsfunction (2 → 0findcalls)Relationship
Same pattern as PR #530 (
git-utils.zsh), applied to the identical construct inutil.zsh.No behavior change
The glob
(N/)is semantically equivalent tofind -type d -maxdepth 1 -name. The subshell-per-directory loop preserves the cd-failure handling from the originalsh -capproach.