Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

why FOO=(${(s/./)ARR[3]}) so slowly?



when i first start my iterm2 (zsh with oh-my-zsh),it's very slow.

After trace, I found function git_compare_version caused, exactly by this line:

INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});

here are a simulate

$ cat zsh-test.sh
#!/usr/bin/env zsh -xv
export PS4=$'%D{%M%S%.} %N:%i> '

INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null));
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});

echo "$INSTALLED_GIT_VERSION"
#!/usr/bin/env zsh -xv
export PS4=$'%D{%M%S%.} %N:%i> '
+./zsh-test.sh:2> export PS4='%D{%M%S%.} %N:%i> '

INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null));
5649865 ./zsh-test.sh:4> INSTALLED_GIT_VERSION=5649867 ./zsh-test.sh:4> git --version
5649865 ./zsh-test.sh:4> INSTALLED_GIT_VERSION=( git version 2.8.4 '(Apple' 'Git-73)' ) 
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
5650999 ./zsh-test.sh:5> INSTALLED_GIT_VERSION=( 2 8 4 )

echo "$INSTALLED_GIT_VERSION"
5650999 ./zsh-test.sh:7> echo '2 8 4'
2 8 4

It's elapsed more than 1 seconds, but when I run it again, it's just elapsed tens of milliseconds
It's just slowly at first run (reboot os). 

why ?

my zsh version: zsh 5.2 (x86_64-apple-darwin16.0.0)


Messages sorted by: Reverse Date, Date, Thread, Author