1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-22 12:20:07 +00:00

speed up p10k display

This commit is contained in:
romkatv 2019-11-04 09:23:57 +01:00
parent d0ff9df8d0
commit 5d729b635d

View file

@ -5764,22 +5764,26 @@ function p10k() {
return 0 return 0
fi fi
shift shift
local opt match MATCH local opt match MATCH prev new pair list name var
local -i k local -i k
for opt; do for opt; do
local pair=(${(s:=:)opt}) pair=(${(s:=:)opt})
local list=(${(s:,:)${pair[2]}}) list=(${(s:,:)${pair[2]}})
for k in ${(u@)_p9k__display_k[(I)$pair[1]]:/(#m)*/$_p9k__display_k[$MATCH]}; do for k in ${(u@)_p9k__display_k[(I)$pair[1]]:/(#m)*/$_p9k__display_k[$MATCH]}; do
local prev=$_p9k__display_v[k+1] if (( $#list == 1 )); then # this branch is purely for optimization
local new=${list[list[(I)$prev]+1]:-$list[1]} [[ $_p9k__display_v[k+1] == $list[1] ]] && continue
[[ $prev == $new ]] && 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 _p9k__display_v[k+1]=$new
local name=$_p9k__display_v[k] name=$_p9k__display_v[k]
if [[ $name == (empty_line|ruler) ]]; then if [[ $name == (empty_line|ruler) ]]; then
local var=_p9k__${name}_i var=_p9k__${name}_i
[[ $new == show ]] && unset $var || typeset -gi $var=3 [[ $new == show ]] && unset $var || typeset -gi $var=3
elif [[ $name == (#b)(<->)([[:IDENT:]/]#) ]]; then elif [[ $name == (#b)(<->)(*) ]]; then
local var=_p9k__${match[1]}${${${${match[2]//\/}/#left/l}/#right/r}/#gap/g} var=_p9k__${match[1]}${${${${match[2]//\/}/#left/l}/#right/r}/#gap/g}
[[ $new == hide ]] && typeset -g $var= || unset $var [[ $new == hide ]] && typeset -g $var= || unset $var
fi fi
if (( __p9k_reset_state > 0 )); then if (( __p9k_reset_state > 0 )); then