875a4553204679cc1e3023a7d0e0bf2cf7d60800

Author
Monson Shao <holymonson@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

perf: `zrecompile` the compdump file to speed up startup (#8802)

Diff

 1diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
 2index 925ee46aaa3467c8b3e82e462cb5213b9dd159a1..d6ef97a07e108057fb5d4753360da77ff6dd245f 100644
 3--- a/oh-my-zsh.sh
 4+++ b/oh-my-zsh.sh
 5@@ -67,7 +67,7 @@ fi
 6 fpath=("$ZSH/functions" "$ZSH/completions" $fpath)
 7 
 8 # Load all stock functions (from $fpath files) called below.
 9-autoload -U compaudit compinit
10+autoload -U compaudit compinit zrecompile
11 
12 # Set ZSH_CUSTOM to the path where your custom config files
13 # and plugins exists, or else we will use the default custom/
14@@ -142,6 +142,9 @@ EOF
15 fi
16 unset zcompdump_revision zcompdump_fpath zcompdump_refresh
17 
18+# zcompile the completion dump file if the .zwc is older or missing.
19+zrecompile -q -p "$ZSH_COMPDUMP" && rm -f "$ZSH_COMPDUMP.zwc.old"
20+
21 # Load all of the config files in ~/oh-my-zsh that end in .zsh
22 # TIP: Add files you don't want in git to .gitignore
23 for config_file ("$ZSH"/lib/*.zsh); do