mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-12 19:18:28 +02:00
further startup speedup: zcompile state dump
This commit is contained in:
parent
aa79dad7e3
commit
60a6ad81dd
@ -3366,30 +3366,29 @@ function _p9k_dump_state() {
|
|||||||
local -i fd
|
local -i fd
|
||||||
sysopen -a -m 600 -o creat,trunc -u fd $tmp || return
|
sysopen -a -m 600 -o creat,trunc -u fd $tmp || return
|
||||||
{
|
{
|
||||||
print -r -- $_p9k_param_sig >&$fd || return
|
|
||||||
local include='_POWERLEVEL9K_*|_p9k_*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED'
|
local include='_POWERLEVEL9K_*|_p9k_*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED'
|
||||||
local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx'
|
local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx'
|
||||||
|
local _p9k_cached_param_sig=$_p9k_param_sig
|
||||||
|
typeset -p _p9k_cached_param_sig >&$fd || return
|
||||||
|
print -r -- '_p9k_restore_state_impl() {' >&$fd || return
|
||||||
typeset -pm "($include)~($exclude)" >&$fd || return
|
typeset -pm "($include)~($exclude)" >&$fd || return
|
||||||
|
print -r -- '}' >&$fd || return
|
||||||
} always {
|
} always {
|
||||||
exec {fd}>&-
|
exec {fd}>&-
|
||||||
}
|
}
|
||||||
zf_mv -f $tmp $_p9k_state_file
|
zf_mv -f $tmp $_p9k_state_file
|
||||||
|
zcompile $_p9k_state_file
|
||||||
}
|
}
|
||||||
|
|
||||||
function _p9k_restore_state() {
|
function _p9k_restore_state() {
|
||||||
[[ -z $_p9k_state_file(#qNW) ]] || return
|
[[ -z $_p9k_state_file(.zwc|)(#qNW) ]] || return
|
||||||
local tmp=$_p9k_state_file.$$-$EPOCHREALTIME-$RANDOM
|
unset _p9k_cached_param_sig
|
||||||
zf_mv -f $_p9k_state_file $tmp 2>/dev/null || return
|
(( $+functions[_p9k_restore_state_impl] )) && unfunction _p9k_restore_state_impl
|
||||||
{
|
source $_p9k_state_file 2>/dev/null || return
|
||||||
[[ -r $tmp ]] || return
|
[[ $_p9k_cached_param_sig == $_p9k_param_sig ]] || return
|
||||||
local sig
|
(( $+functions[_p9k_restore_state_impl] )) || return
|
||||||
IFS='' read -r sig <$tmp || return
|
_p9k_restore_state_impl
|
||||||
[[ $sig == $_p9k_param_sig ]] || return
|
_p9k_state_restored=1
|
||||||
source $tmp || return
|
|
||||||
_p9k_state_restored=1
|
|
||||||
} always {
|
|
||||||
zf_mv -f $tmp $_p9k_state_file 2>/dev/null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_p9k_precmd_impl() {
|
_p9k_precmd_impl() {
|
||||||
@ -4362,7 +4361,7 @@ _p9k_must_init() {
|
|||||||
'${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}'
|
'${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}'
|
||||||
'${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}'
|
'${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}'
|
||||||
'${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v0')
|
'${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v0')
|
||||||
IFS=$'\2' param_sig="#${(e)param_sig}"
|
IFS=$'\2' param_sig="${(e)param_sig}"
|
||||||
[[ $param_sig == $_p9k_param_sig ]] && return 1
|
[[ $param_sig == $_p9k_param_sig ]] && return 1
|
||||||
[[ -n $_p9k_param_sig ]] && _p9k_deinit
|
[[ -n $_p9k_param_sig ]] && _p9k_deinit
|
||||||
typeset -g _p9k_param_sig=$param_sig
|
typeset -g _p9k_param_sig=$param_sig
|
||||||
|
Loading…
Reference in New Issue
Block a user