Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Performance of _store_cache and _retrieve_cache



On 8 Feb, Bart wrote:
> _zsh_all_pkgs=( "${(zQ)$(<<\EO:_zsh_all_pkgs
> '02exercicio' '0x10c-asm' ...
> EO:_zsh_all_pkgs
> )}" )

This is removing the quotes before doing the word splitting so breaks
if there are values that need quoting. It works with another level of
nesting as in the patch below. I timed some tests and this is still much
faster than the original given a large enough array.

For a good example of this failing, set the extra-verbose style and do
command completion. Note that you'll only see problems when
_command_descriptions is loaded from the cache.

Oliver

diff --git a/Completion/Base/Utility/_store_cache b/Completion/Base/Utility/_store_cache
index 8feaee6..fb2ab32 100644
--- a/Completion/Base/Utility/_store_cache
+++ b/Completion/Base/Utility/_store_cache
@@ -49,10 +49,10 @@ if zstyle -t ":completion:${curcontext}:" use-cache; then
     (*(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 "$var=( "'${(Q)"${(z)$(<<\EO:'"$var"
 	print -r "${(kv@Pqq)^^var}"
 	print -r "EO:$var"
-	print -r ')}" )'
+	print -r ')}"} )'
 	;;
     (*) print -r "$var=${(Pqq)^^var}";;
     esac



Messages sorted by: Reverse Date, Date, Thread, Author