From: dana <dana@dana.is>
To: Zsh workers <zsh-workers@zsh.org>
Subject: [PATCH] _multi_parts: Improve match performance
Date: Sun, 23 Dec 2018 05:56:43 -0600 [thread overview]
Message-ID: <5B40A4D4-49B5-4D46-8C7F-8FAA16AF90BE@dana.is> (raw)
Re: workers/43914: The hanging loop i mentioned was actually introduced in
workers/28186. Before that it used an array filter with a pattern match, but
that had to be removed due to problems with special characters. Now that we
have the (b) flag, we can put it back. It's much faster.
I also mentioned skipping the check entirely when there's no prefix or suffix
currently on the command line, and after testing various scenarios with it i
*think* that's OK to do. So i did that as well
dana
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
reply other threads:[~2018-12-23 11:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5B40A4D4-49B5-4D46-8C7F-8FAA16AF90BE@dana.is \
--to=dana@dana.is \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).