1
0
Fork 0
mirror of synced 2024-11-22 15:25: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() {
local zopt_find zopt_rm zdir
if (( ! _zquiet )); then
zopt_find='-print'
zopt_rm='-v'
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
local zopt
(( ! _zquiet )) && zopt='-v'
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -exec rm -f ${zopt} {} \; || return 1
command rm -f ${zopt} <%= home %>/<%= startup_files_glob %>.zwc(|.old)(N) || return 1
if (( ! _zquiet )); then
print -P '<%= done %>Done with clean-compiled. Run %Bzimfw compile%b to re-compile.'
fi

View file

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

View file

@ -1,7 +1,7 @@
() {
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
autoload -U zrecompile
local zdumpfile zdir zfile
autoload -Uz zrecompile
local zdumpfile zfile
# Compile the completion cache; significant speedup
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
@ -9,21 +9,13 @@
zrecompile -p ${1} ${zdumpfile} || return 1
fi
# Compile .zshrc
zrecompile -p ${1} <%= home %>/.zshrc || 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
# Compile Zsh startup files
for zfile in ${1} <%= home %>/<%= startup_files_glob %>(N-.); do
zrecompile -p ${1} ${zfile} || return 1
done
# Compile scripts
for zfile in ${ZIM_HOME}/(^*test*/)#*.zsh{,-theme}(N-.); do
# Compile Zim scripts
for zfile in ${ZIM_HOME}/(^*test*/)#*.zsh(|-theme)(N-.); do
zrecompile -p ${1} ${zfile} || return 1
done

View file

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

View file

@ -67,8 +67,8 @@ _zimfw_build_login_init() {
_zimfw_mv =(
print -Rn "() {
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
autoload -U zrecompile
local zdumpfile zdir zfile
autoload -Uz zrecompile
local zdumpfile zfile
# Compile the completion cache; significant speedup
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=\${ZDOTDIR:-\${HOME}}/.zcompdump
@ -76,21 +76,13 @@ _zimfw_build_login_init() {
zrecompile -p \${1} \${zdumpfile} || return 1
fi
# Compile .zshrc
zrecompile -p \${1} \${ZDOTDIR:-\${HOME}}/.zshrc || 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
# Compile Zsh startup files
for zfile in \${1} \${ZDOTDIR:-\${HOME}}/.z(shenv|shrc|login|logout)(N-.); do
zrecompile -p \${1} \${zfile} || return 1
done
# Compile scripts
for zfile in \${ZIM_HOME}/(^*test*/)#*.zsh{,-theme}(N-.); do
# Compile Zim scripts
for zfile in \${ZIM_HOME}/(^*test*/)#*.zsh(|-theme)(N-.); do
zrecompile -p \${1} \${zfile} || return 1
done
@ -247,19 +239,10 @@ _zimfw_source_zimrc() {
}
_zimfw_clean_compiled() {
local zopt_find zopt_rm zdir
if (( ! _zquiet )); then
zopt_find='-print'
zopt_rm='-v'
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
local zopt
(( ! _zquiet )) && zopt='-v'
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -exec rm -f ${zopt} {} \; || return 1
command rm -f ${zopt} ${ZDOTDIR:-${HOME}}/.z(shenv|shrc|login|logout).zwc(|.old)(N) || return 1
if (( ! _zquiet )); then
print -P 'Done with clean-compiled. Run %Bzimfw compile%b to re-compile.'
fi
@ -269,7 +252,7 @@ _zimfw_clean_dumpfile() {
local zdumpfile zopt
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=${ZDOTDIR:-${HOME}}/.zcompdump
(( ! _zquiet )) && zopt='-v'
command rm -f ${zopt} ${zdumpfile}{,.zwc{,.old}} || return 1
command rm -f ${zopt} ${zdumpfile}(|.zwc(|.old)) || return 1
if (( ! _zquiet )); then
print -P 'Done with clean-dumpfile. Restart your terminal to dump an updated configuration.'
fi
@ -280,7 +263,7 @@ _zimfw_compile() {
}
_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 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a)