There's no point in calling a separate function that is only used in one place. Specially considering that there's no need to call compgen, and we traverse the words ourselves both in __gitcompadd, and __gitcomp_1. So lets squash the functions together, and traverse only once. This improves performance. No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> --- contrib/completion/git-completion.bash | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 0b72f24..82ea7b1 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -56,19 +56,6 @@ __gitdir () fi } -__gitcomp_1 () -{ - local c IFS=$' \t\n' - for c in $1; do - c="$c$2" - case $c in - --*=*|*.) ;; - *) c="$c " ;; - esac - printf '%s\n' "$c" - done -} - # The following function is based on code from: # # bash_completion - programmable completion functions for bash 3.2+ @@ -250,8 +237,17 @@ __gitcomp () --*=) ;; *) - local IFS=$'\n' - __gitcompadd "$(__gitcomp_1 "${1-}" "${4-}")" "${2-}" "$cur_" "" + local c i=0 IFS=$' \t\n' + for c in $1; do + c="$c${4-}" + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + if [[ $c == "$cur_"* ]]; then + COMPREPLY[i++]="${2-}$c" + fi + done ;; esac } -- 1.8.0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html