mirror of
https://github.com/pyenv/pyenv.git
synced 2026-06-06 00:48:13 +09:00
pyenv-latest: fast path for when there is an exact match (#3437)
Avoids O(N^2) complexity when `pyenv-latest` is called in a loop for existing entries
This commit is contained in:
parent
dfb1a96c3e
commit
6481d1451d
@ -10,6 +10,7 @@
|
|||||||
set -e
|
set -e
|
||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]
|
while [[ $# -gt 0 ]]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -38,6 +39,10 @@ exitcode=0
|
|||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
|
||||||
if [[ -z $FROM_KNOWN ]]; then
|
if [[ -z $FROM_KNOWN ]]; then
|
||||||
|
if [[ -d $PYENV_ROOT/versions/$prefix ]]; then
|
||||||
|
echo "$prefix"
|
||||||
|
exit $exitcode;
|
||||||
|
fi
|
||||||
DEFINITION_CANDIDATES=( $(pyenv-versions --bare --skip-envs) )
|
DEFINITION_CANDIDATES=( $(pyenv-versions --bare --skip-envs) )
|
||||||
else
|
else
|
||||||
DEFINITION_CANDIDATES=( $(python-build --definitions ) )
|
DEFINITION_CANDIDATES=( $(python-build --definitions ) )
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user