diff options
author | Anders Kaseorg <andersk@MIT.EDU> | 2013-01-22 13:46:42 +0100 |
---|---|---|
committer | Claude Paroz <claude@2xlibre.net> | 2013-01-22 13:50:10 +0100 |
commit | e535da6865f0e02f0b593b52ed2e040b24a886d6 (patch) | |
tree | 2a2f951a46f2cabfafc1c57740644d1c79f6c14b /extras | |
parent | cc4de61a2b36abf418d6f4c720d9e62c405e0612 (diff) | |
download | django-e535da6865f0e02f0b593b52ed2e040b24a886d6.tar.gz |
Fixed #19523 -- Improved performance of Django's bash completion
Previous version took about 150ms to source, even on a warm cache,
primarily because it forks+execs /usr/bin/basename 44 times.
This patch makes it faster by a factor of 5 (and I imagine that a little
more thought would reduce the time to effectively zero).
Diffstat (limited to 'extras')
-rwxr-xr-x | extras/django_bash_completion | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/extras/django_bash_completion b/extras/django_bash_completion index 1c3887eba0..8f85211705 100755 --- a/extras/django_bash_completion +++ b/extras/django_bash_completion @@ -42,10 +42,10 @@ complete -F _django_completion -o default django-admin.py manage.py django-admin _python_django_completion() { if [[ ${COMP_CWORD} -ge 2 ]]; then - PYTHON_EXE=$( basename -- ${COMP_WORDS[0]} ) + PYTHON_EXE=${COMP_WORDS[0]##*/} echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1 if [[ $? == 0 ]]; then - PYTHON_SCRIPT=$( basename -- ${COMP_WORDS[1]} ) + PYTHON_SCRIPT=${COMP_WORDS[1]##*/} echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1 if [[ $? == 0 ]]; then COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \ @@ -61,7 +61,7 @@ unset pythons if command -v whereis &>/dev/null; then python_interpreters=$(whereis python | cut -d " " -f 2-) for python in $python_interpreters; do - pythons="${pythons} $(basename -- $python)" + pythons="${pythons} ${python##*/}" done pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ") else |