Re: [PATCH] emacs: When completing tags, offer each tag once

Subject: Re: [PATCH] emacs: When completing tags, offer each tag once

Date: Tue, 02 Feb 2021 21:53:28 +0200

To: David Bremner, David Edmondson, notmuch@notmuchmail.org

Cc:

From: Tomi Ollila


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
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: