rehash: Drop redundant sort -u from make_shims call#3410
Merged
native-api merged 1 commit intopyenv:masterfrom Mar 1, 2026
Merged
rehash: Drop redundant sort -u from make_shims call#3410native-api merged 1 commit intopyenv:masterfrom
native-api merged 1 commit intopyenv:masterfrom
Conversation
register_shim() already deduplicates via associative array (bash 4+) or string-containment check (bash 3.2). The sort -u pipe in the make_shims call is redundant -- the dedup happens downstream regardless. Shim creation is order-independent and idempotent, so sorting has no semantic effect either. Saves one subprocess fork during every rehash invocation.
native-api
reviewed
Mar 1, 2026
Comment on lines
170
to
180
| register_shim() { | ||
| registered_shims="${registered_shims}${1} " | ||
| } | ||
|
|
||
| install_registered_shims() { | ||
| local shim file | ||
| for shim in $registered_shims; do | ||
| file="${SHIM_PATH}/${shim}" | ||
| [ -e "$file" ] || cp "$PROTOTYPE_SHIM_PATH" "$file" | ||
| done | ||
| } |
Member
There was a problem hiding this comment.
The Bash 3 path does not handle duplicate names with "substring match" as the PR description claims. It does however handle them with [ -e "$file" ] before creating a shim.
So accepting with an altered description
native-api
approved these changes
Mar 1, 2026
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.
The
make_shimscall inpyenv-rehashpipeslist_executable_namesthroughsort -ubefore processing. This deduplication is redundant:register_shim()already handles duplicates via associative array (bash 4+) or string matching (bash 3.2).Removing the pipe saves one subprocess fork during
pyenv rehash.Before:
make_shims $(list_executable_names | sort -u)After:
make_shims $(list_executable_names)All existing tests pass. The change is behavior-preserving: shim creation is order-independent and duplicates are handled downstream.