1
0
Fork 0
mirror of synced 2024-11-26 09:15:34 -05:00

Don't create function digest files

At least until Zsh version 5.7.1, no performance improvement is observed
out of using those.

In some cases, the performance is even worsened, like when using

    autoload -w functions_digest.zwc

instead of

    autoload func_name1 func_name2 ...
This commit is contained in:
Eric Nielsen 2019-12-27 09:51:02 -05:00
parent c13fe60b02
commit ae3e71cb84
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
5 changed files with 28 additions and 61 deletions

View file

@ -1,17 +1,8 @@
_zimfw_clean_compiled() { _zimfw_clean_compiled() {
local zopt_find zopt_rm zdir local zopt
if (( ! _zquiet )); then (( ! _zquiet )) && zopt='-v'
zopt_find='-print' command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -exec rm -f ${zopt} {} \; || return 1
zopt_rm='-v' command rm -f ${zopt} <%= home %>/<%= startup_files_glob %>.zwc(|.old)(N) || return 1
fi
for zdir in ${fpath}; do
[[ ${zdir} == (.|..) || ${zdir} == (.|..)/* ]] && continue
if [[ -w ${zdir:h} ]]; then
command rm -f ${zopt_rm} ${zdir}.zwc{,.old} || return 1
fi
done
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -delete ${zopt_find} || return 1
command rm -f ${zopt_rm} <%= home %>/.zshrc.zwc{,.old} || return 1
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '<%= done %>Done with clean-compiled. Run %Bzimfw compile%b to re-compile.' print -P '<%= done %>Done with clean-compiled. Run %Bzimfw compile%b to re-compile.'
fi fi

View file

@ -2,7 +2,7 @@ _zimfw_clean_dumpfile() {
local zdumpfile zopt local zdumpfile zopt
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
(( ! _zquiet )) && zopt='-v' (( ! _zquiet )) && zopt='-v'
command rm -f ${zopt} ${zdumpfile}{,.zwc{,.old}} || return 1 command rm -f ${zopt} ${zdumpfile}(|.zwc(|.old)) || return 1
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '<%= done %>Done with clean-dumpfile. Restart your terminal to dump an updated configuration.' print -P '<%= done %>Done with clean-dumpfile. Restart your terminal to dump an updated configuration.'
fi fi

View file

@ -1,7 +1,7 @@
() { () {
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
autoload -U zrecompile autoload -Uz zrecompile
local zdumpfile zdir zfile local zdumpfile zfile
# Compile the completion cache; significant speedup # Compile the completion cache; significant speedup
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
@ -9,21 +9,13 @@
zrecompile -p ${1} ${zdumpfile} || return 1 zrecompile -p ${1} ${zdumpfile} || return 1
fi fi
# Compile .zshrc # Compile Zsh startup files
zrecompile -p ${1} <%= home %>/.zshrc || return 1 for zfile in ${1} <%= home %>/<%= startup_files_glob %>(N-.); do
zrecompile -p ${1} ${zfile} || return 1
# Compile autoloaded functions, taken from zrecompile doc in zshcontrib(1)
for zdir in ${fpath}; do
[[ ${zdir} == (.|..) || ${zdir} == (.|..)/* ]] && continue
zfile=(${zdir}/^(*.*)(N-.))
if [[ -w ${zdir:h} && -n ${zfile} ]]; then
zfile=(${${(M)zfile%/*/*}#/})
(builtin cd -q ${zdir:h} && zrecompile -p ${1} ${zdir:t}.zwc ${zfile}) || return 1
fi
done done
# Compile scripts # Compile Zim scripts
for zfile in ${ZIM_HOME}/(^*test*/)#*.zsh{,-theme}(N-.); do for zfile in ${ZIM_HOME}/(^*test*/)#*.zsh(|-theme)(N-.); do
zrecompile -p ${1} ${zfile} || return 1 zrecompile -p ${1} ${zfile} || return 1
done done

View file

@ -1,11 +1,12 @@
<% <%
class Zim class Zim
attr_reader :home, :min_zsh_version, :script_filename, :version, :ellipsis, :okay, :error, :done, :failed attr_reader :home, :min_zsh_version, :script_filename, :startup_files_glob, :version, :ellipsis, :okay, :error, :done, :failed
def initialize def initialize
@home = "${ZDOTDIR:-${HOME}}" @home = "${ZDOTDIR:-${HOME}}"
@min_zsh_version = "5.2" @min_zsh_version = "5.2"
@script_filename = "zimfw.zsh" @script_filename = "zimfw.zsh"
@startup_files_glob = ".z(shenv|shrc|login|logout)"
@version = "1.0.0-SNAPSHOT" @version = "1.0.0-SNAPSHOT"
@ellipsis = " ..." @ellipsis = " ..."
@okay = "%F{green})%f " @okay = "%F{green})%f "
@ -23,7 +24,7 @@ class Zim
end end
def render_escaped(filename) def render_escaped(filename)
render(filename).gsub(/(\$[^']|"|`)/, "\\\\\\1") render(filename).gsub(/(?=\$[^']|"|`)/, "\\\\")
end end
def render_commented(filename) def render_commented(filename)

View file

@ -67,8 +67,8 @@ _zimfw_build_login_init() {
_zimfw_mv =( _zimfw_mv =(
print -Rn "() { print -Rn "() {
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
autoload -U zrecompile autoload -Uz zrecompile
local zdumpfile zdir zfile local zdumpfile zfile
# Compile the completion cache; significant speedup # Compile the completion cache; significant speedup
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=\${ZDOTDIR:-\${HOME}}/.zcompdump zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=\${ZDOTDIR:-\${HOME}}/.zcompdump
@ -76,21 +76,13 @@ _zimfw_build_login_init() {
zrecompile -p \${1} \${zdumpfile} || return 1 zrecompile -p \${1} \${zdumpfile} || return 1
fi fi
# Compile .zshrc # Compile Zsh startup files
zrecompile -p \${1} \${ZDOTDIR:-\${HOME}}/.zshrc || return 1 for zfile in \${1} \${ZDOTDIR:-\${HOME}}/.z(shenv|shrc|login|logout)(N-.); do
zrecompile -p \${1} \${zfile} || return 1
# Compile autoloaded functions, taken from zrecompile doc in zshcontrib(1)
for zdir in \${fpath}; do
[[ \${zdir} == (.|..) || \${zdir} == (.|..)/* ]] && continue
zfile=(\${zdir}/^(*.*)(N-.))
if [[ -w \${zdir:h} && -n \${zfile} ]]; then
zfile=(\${\${(M)zfile%/*/*}#/})
(builtin cd -q \${zdir:h} && zrecompile -p \${1} \${zdir:t}.zwc \${zfile}) || return 1
fi
done done
# Compile scripts # Compile Zim scripts
for zfile in \${ZIM_HOME}/(^*test*/)#*.zsh{,-theme}(N-.); do for zfile in \${ZIM_HOME}/(^*test*/)#*.zsh(|-theme)(N-.); do
zrecompile -p \${1} \${zfile} || return 1 zrecompile -p \${1} \${zfile} || return 1
done done
@ -247,19 +239,10 @@ _zimfw_source_zimrc() {
} }
_zimfw_clean_compiled() { _zimfw_clean_compiled() {
local zopt_find zopt_rm zdir local zopt
if (( ! _zquiet )); then (( ! _zquiet )) && zopt='-v'
zopt_find='-print' command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -exec rm -f ${zopt} {} \; || return 1
zopt_rm='-v' command rm -f ${zopt} ${ZDOTDIR:-${HOME}}/.z(shenv|shrc|login|logout).zwc(|.old)(N) || return 1
fi
for zdir in ${fpath}; do
[[ ${zdir} == (.|..) || ${zdir} == (.|..)/* ]] && continue
if [[ -w ${zdir:h} ]]; then
command rm -f ${zopt_rm} ${zdir}.zwc{,.old} || return 1
fi
done
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -delete ${zopt_find} || return 1
command rm -f ${zopt_rm} ${ZDOTDIR:-${HOME}}/.zshrc.zwc{,.old} || return 1
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P 'Done with clean-compiled. Run %Bzimfw compile%b to re-compile.' print -P 'Done with clean-compiled. Run %Bzimfw compile%b to re-compile.'
fi fi
@ -269,7 +252,7 @@ _zimfw_clean_dumpfile() {
local zdumpfile zopt local zdumpfile zopt
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=${ZDOTDIR:-${HOME}}/.zcompdump zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=${ZDOTDIR:-${HOME}}/.zcompdump
(( ! _zquiet )) && zopt='-v' (( ! _zquiet )) && zopt='-v'
command rm -f ${zopt} ${zdumpfile}{,.zwc{,.old}} || return 1 command rm -f ${zopt} ${zdumpfile}(|.zwc(|.old)) || return 1
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P 'Done with clean-dumpfile. Restart your terminal to dump an updated configuration.' print -P 'Done with clean-dumpfile. Restart your terminal to dump an updated configuration.'
fi fi
@ -280,7 +263,7 @@ _zimfw_compile() {
} }
_zimfw_info() { _zimfw_info() {
print 'Zim version: 1.0.0-SNAPSHOT (previous commit is 86f177a)' print 'Zim version: 1.0.0-SNAPSHOT (previous commit is 94526d6)'
print -R 'ZIM_HOME: '${ZIM_HOME} print -R 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION} print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a) print -R 'System info: '$(command uname -a)