summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-02-12 09:31:09 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2015-02-12 09:31:09 -0800
commitae7dcab5ed1882b6115c9fe3ab7894a8b6a7e9eb (patch)
tree019b25ca33805f7fc9e51d8672938032f0d7790c
parent7398fea05980df98a29eac6f504397ea0cb3be7a (diff)
downloadzsh-ae7dcab5ed1882b6115c9fe3ab7894a8b6a7e9eb.tar.gz
zsh-ae7dcab5ed1882b6115c9fe3ab7894a8b6a7e9eb.tar.xz
zsh-ae7dcab5ed1882b6115c9fe3ab7894a8b6a7e9eb.zip
34476: change _store_cache assignment format
Avoids potentially expensive lexical analysis of the array values.
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Base/Utility/_store_cache11
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4191a9198..47c3c8d1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@
 	Back out 34485, an alternate solution needs to be worked
 	out.  (Tweaked to keep the unrelated hunk of the E01 test.)
 
+	* 34476: Completion/Base/Utility/_store_cache: change the
+	assignment format to avoid potentially expensive lexical
+	analysis of the array values
+
 2015-02-11  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* users/19850: Doc/Zsh/params.yo, Src/watch.c: watch variable
diff --git a/Completion/Base/Utility/_store_cache b/Completion/Base/Utility/_store_cache
index 86e72e9a9..8feaee6f7 100644
--- a/Completion/Base/Utility/_store_cache
+++ b/Completion/Base/Utility/_store_cache
@@ -46,8 +46,15 @@ if zstyle -t ":completion:${curcontext}:" use-cache; then
   for var; do
     case ${(Pt)var} in
     (*readonly*) ;;
-    (*(association|array)*) print -r "$var=( ${(kv@Pqq)^^var} )";;
-    (*)                     print -r "$var=${(Pqq)^^var}";;
+    (*(association|array)*)
+	# Dump the array as a here-document to reduce parsing overhead
+	# when reloading the cache with "source" from _retrieve_cache
+	print -r "$var=( "'"${(zQ)$(<<\EO:'"$var"
+	print -r "${(kv@Pqq)^^var}"
+	print -r "EO:$var"
+	print -r ')}" )'
+	;;
+    (*) print -r "$var=${(Pqq)^^var}";;
     esac
   done >! "$_cache_dir/$_cache_ident"
 else