unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>, David Edmondson <dme@dme.org>,
	notmuch@notmuchmail.org
Subject: Re: [PATCH] emacs: When completing tags, offer each tag once
Date: Tue, 02 Feb 2021 21:53:28 +0200	[thread overview]
Message-ID: <m21rdygsav.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <871rdyxoip.fsf@tethera.net>

On Tue, Feb 02 2021, David Bremner wrote:

>
> Maybe delete-dups (subr.el) would be useful here? It is destructive, but
> even with a copy (if needed), it should still be faster.

I looked the implementation of delete-dups. In case of >100 elements, it
uses hash table for checking duplicates. less than 101 elements and
the code is

      (let ((tail list))
        (while tail
          (setcdr tail (delete (car tail) (cdr tail)))
          (setq tail (cdr tail))))))

It took me a bit of time to understand, but then I got it:

* delete all elements that match car of tail in the list of (cdr tail)
* set tail to cdr of tail
* redo until tail exhausted

setcdr and delete are built-in functions implemented in c code

(and copy-sequence, unsurprisingly, is implemented in c (if needed))

>
> d

Tomi

      reply	other threads:[~2021-02-02 19:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 14:54 [PATCH] emacs: When completing tags, offer each tag once David Edmondson
2021-02-01 15:49 ` David Bremner
2021-02-01 16:13   ` David Edmondson
2021-02-02 19:09     ` Tomi Ollila
2021-02-02 19:23       ` David Bremner
2021-02-02 19:53         ` Tomi Ollila [this message]

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

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m21rdygsav.fsf@guru.guru-group.fi \
    --to=tomi.ollila@iki.fi \
    --cc=david@tethera.net \
    --cc=dme@dme.org \
    --cc=notmuch@notmuchmail.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://yhetil.org/notmuch.git/

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 read-only IMAP folder(s) and NNTP newsgroup(s).