aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-11-04 11:23:57 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-11-04 11:23:57 +0300
commit5d729b635dff90deab6fce2da815c3ec3fb6437d (patch)
treeb41acaaae9b8816b7c14a1189cc55398c8df18ef /internal/p10k.zsh
parentd0ff9df8d06e6ada15ba8fe5dbffb74b4a21c122 (diff)
speed up p10k display
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r--internal/p10k.zsh24
1 files changed, 14 insertions, 10 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index aecb2142..f0b9ed44 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -5764,22 +5764,26 @@ function p10k() {
return 0
fi
shift
- local opt match MATCH
+ local opt match MATCH prev new pair list name var
local -i k
for opt; do
- local pair=(${(s:=:)opt})
- local list=(${(s:,:)${pair[2]}})
+ pair=(${(s:=:)opt})
+ list=(${(s:,:)${pair[2]}})
for k in ${(u@)_p9k__display_k[(I)$pair[1]]:/(#m)*/$_p9k__display_k[$MATCH]}; do
- local prev=$_p9k__display_v[k+1]
- local new=${list[list[(I)$prev]+1]:-$list[1]}
- [[ $prev == $new ]] && continue
+ if (( $#list == 1 )); then # this branch is purely for optimization
+ [[ $_p9k__display_v[k+1] == $list[1] ]] && continue
+ new=$list[1]
+ else
+ new=${list[list[(I)$_p9k__display_v[k+1]]+1]:-$list[1]}
+ [[ $_p9k__display_v[k+1] == $new ]] && continue
+ fi
_p9k__display_v[k+1]=$new
- local name=$_p9k__display_v[k]
+ name=$_p9k__display_v[k]
if [[ $name == (empty_line|ruler) ]]; then
- local var=_p9k__${name}_i
+ var=_p9k__${name}_i
[[ $new == show ]] && unset $var || typeset -gi $var=3
- elif [[ $name == (#b)(<->)([[:IDENT:]/]#) ]]; then
- local var=_p9k__${match[1]}${${${${match[2]//\/}/#left/l}/#right/r}/#gap/g}
+ elif [[ $name == (#b)(<->)(*) ]]; then
+ var=_p9k__${match[1]}${${${${match[2]//\/}/#left/l}/#right/r}/#gap/g}
[[ $new == hide ]] && typeset -g $var= || unset $var
fi
if (( __p9k_reset_state > 0 )); then