zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: Fix inverted condition for unique completions
Date: Tue, 15 Mar 2022 12:56:48 +0100	[thread overview]
Message-ID: <20220315115648.10521-1-mikachu@gmail.com> (raw)

This change makes most-recent-file[1] completion take a few milliseconds
instead of close to a minute in a directory of 30000 files. I'm not sure
exactly what's going on with these flags, but surely if they are not set,
then we should not deduplicate the set of matches. Most likely this was
a thinko-copy-paste-o from the first NOSORT case which does have to be
negated. I'm not sure why regular tab-press was always fast, but it is
still fast after this change for me.

I don't know when these flags are supposed to be set, so I haven't tested
that case.

[1]
zstyle ':completion:(*-|)most-recent-file:*' match-original both
zstyle ':completion:(*-|)most-recent-file:*' file-sort modification
zstyle ':completion:(*-|)most-recent-file:*' file-patterns '*:all\ files'
zstyle ':completion:most-recent-file:*' hidden all
zstyle ':completion:(*-|)most-recent-file:*' completer _files

---

This bug is present since before cvs, according to git blame.

 Src/Zle/compcore.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index ebcd7d85bb..778a4ff571 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -3254,7 +3254,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
 	    qsort((void *) rp, n, sizeof(Cmatch),
 		  (int (*) _((const void *, const void *)))matchcmp);
 
-	    if (!(flags & CGF_UNIQCON)) {
+	    if (flags & CGF_UNIQCON) {
 		int dup;
 
 		/* And delete the ones that occur more than once. */
@@ -3280,7 +3280,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
 		    nl++;
 	    }
 	} else {
-	    if (!(flags & CGF_UNIQALL) && !(flags & CGF_UNIQCON)) {
+	    if (flags & CGF_UNIQALL) {
                 int dup;
 
 		for (ap = rp; *ap; ap++) {
@@ -3303,7 +3303,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
                             (*ap)->flags |= CMF_FMULT;
                     }
 		}
-	    } else if (!(flags & CGF_UNIQCON)) {
+	    } else if (flags & CGF_UNIQCON) {
 		int dup;
 
 		for (ap = cp = rp; *ap; ap++) {
-- 
2.15.1



             reply	other threads:[~2022-03-15 11:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 11:56 Mikael Magnusson [this message]
2022-03-17 17:08 ` Mikael Magnusson
2022-03-17 19:17   ` Bart Schaefer
2022-03-17 19:32     ` Mikael Magnusson
2022-03-26  1:40       ` PATCH 1/2: Fix comments for UNIQCON/ALL Mikael Magnusson
2022-03-26  1:43         ` PATCH 2/2: [WIP] Efficient dedup for unsorted completions Mikael Magnusson
2022-03-29 16:07           ` PATCHv2 2/2: " Mikael Magnusson
2022-03-30 16:41           ` PATCH 2/2: [WIP] " Bart Schaefer
2022-03-30 18:33             ` Mikael Magnusson

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=20220315115648.10521-1-mikachu@gmail.com \
    --to=mikachu@gmail.com \
    --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).