From 446411dc6424556d7f19a625af5098b992919c39 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Thu, 2 Feb 2023 17:58:10 +0300 Subject: [PATCH] Streamline `pyenv-versions --bare' Achieves a ~20% speedup. As it's used in pyenv-latest, this affects all version lookups --- libexec/pyenv-versions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libexec/pyenv-versions b/libexec/pyenv-versions index 285d7a7f..3aaaa055 100755 --- a/libexec/pyenv-versions +++ b/libexec/pyenv-versions @@ -71,8 +71,6 @@ else current_versions=() fi if [ -n "$bare" ]; then - hit_prefix="" - miss_prefix="" include_system="" else hit_prefix="* " @@ -106,8 +104,12 @@ exists() { print_version() { local version="${1:?}" + if [[ -n $bare ]]; then + echo "$version" + return + fi local path="${2:?}" - if [[ -z "$bare" && -L "$path" ]]; then + if [[ -L "$path" ]]; then # Only resolve the link itself for printing, do not resolve further. # Doing otherwise would misinform the user of what the link contains. version_repr="$version --> $(resolve_link "$path")"