From efd235ab529b3967d6493d28f4430dd4c3726525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Thu, 16 May 2013 22:31:34 +0200 Subject: [PATCH] Optimize _lp_are_vcs_disabled (renamed to _are_vcs_enabled) Use return code for the boolean return value instead of inefficient usage of string values. --- liquidprompt | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/liquidprompt b/liquidprompt index 9cc75a7..ef7bf3b 100755 --- a/liquidprompt +++ b/liquidprompt @@ -668,18 +668,15 @@ _lp_return_value() # VCS branch display # ###################### -_lp_are_vcs_disabled() +_lp_are_vcs_enabled() { - [[ -z "$LP_DISABLED_VCS_PATH" ]] && echo 0 && return + [[ -z "$LP_DISABLED_VCS_PATH" ]] && return 0 local path local IFS=: for path in $LP_DISABLED_VCS_PATH; do - if [[ "$PWD" == *"$path"* ]]; then - echo 1 - return - fi + [[ "$PWD" == *"$path"* ]] && return 1 done - echo 0 + return 0 } # GIT # @@ -1421,16 +1418,15 @@ _lp_set_prompt() LP_PWD=$(_lp_shorten_path) [[ -n "$PROMPT_DIRTRIM" ]] && PROMPT_DIRTRIM=$(_lp_get_dirtrim) - if [[ "$(_lp_are_vcs_disabled)" -eq "0" ]] ; then + if _lp_are_vcs_enabled; then LP_VCS="$(_lp_git_branch_color)" LP_VCS_TYPE="git" if [[ -n "$LP_VCS" ]]; then # If this is a git-svn repository if [[ -d "$(git rev-parse --git-dir 2>/dev/null)/svn" ]]; then LP_VCS_TYPE="git-svn" - fi - fi # git-svn - if [[ -z "$LP_VCS" ]]; then + fi # git-svn + else LP_VCS="$(_lp_hg_branch_color)" LP_VCS_TYPE="hg" if [[ -z "$LP_VCS" ]]; then