summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordana <dana@dana.is>2018-12-30 09:38:06 -0600
committerdana <dana@dana.is>2018-12-30 09:38:06 -0600
commit79fae27f7c66018d5e3cdb92193982dab10a05e4 (patch)
tree2ca3422ff99edce64bc1fe4412b6e79975f5b846
parent7951ede1dbb756aa3d6e81ee05fd9a63138066a1 (diff)
downloadzsh-79fae27f7c66018d5e3cdb92193982dab10a05e4.tar.gz
zsh-79fae27f7c66018d5e3cdb92193982dab10a05e4.zip
43930: Improve _multi_parts performance
-rw-r--r--ChangeLog2
-rw-r--r--Completion/Base/Utility/_multi_parts16
2 files changed, 11 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 61702caa8..7d99c7e17 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2018-12-30 dana <dana@dana.is>
+ * 43930: Completion/Base/Utility/_multi_parts: Improve performance
+
* unposted (per 43938): Src/utils.c: Avoid segfault when
unmetafying empty string
diff --git a/Completion/Base/Utility/_multi_parts b/Completion/Base/Utility/_multi_parts
index 3e2f36c9c..12ff965ed 100644
--- a/Completion/Base/Utility/_multi_parts
+++ b/Completion/Base/Utility/_multi_parts
@@ -127,8 +127,7 @@ while true; do
return
fi
elif (( $#tmp1 )); then
- local ret=1 tt
- local -a mm
+ local ret=1
# More than one match. First we get all strings that match the
# rest from the line.
@@ -145,11 +144,14 @@ while true; do
SUFFIX="$suf"
fi
- for tt in $tmp1
- do
- mm+=( "${(@M)matches:#$tt*}" )
- done
- matches=( $mm )
+ # The purpose of this check (or one purpose, anyway) seems to be to ensure
+ # that the suffix for the current segment on the command line doesn't
+ # match across segments. For example, we want $matches for a<TAB>c to
+ # include abc/d, but not abd/c. If we don't have anything on the command
+ # line for this segment, though, we can skip it. (The difference is only
+ # noticeable when there are a huge number of possibilities)
+ [[ -n $pre$suf ]] &&
+ matches=( ${(@M)matches:#(${(j<|>)~${(@b)tmp1}})*} )
if ! zstyle -t ":completion:${curcontext}:" expand suffix ||
[[ -n "$menu" || -z "$compstate[insert]" ]]; then