Subject: 29.0.50; Performance of seq-uniq is not very good

From: Stefan Kangas <[email-masked]>
Date: Tue, 9 Aug 2022 09:11:07 -0700

Severity: minor

`seq-uniq' is not very performant compared to `-uniq' (from dash.el) and
even slower compared to the recently removed `gnus-delete-duplicates':

    (benchmark-run 10000 (seq-uniq '(a c b c c a d)))
    => (0.355001481 1 0.2518970439999748)

    (benchmark-run 10000 (-uniq '(a c b c c a d)))
    => (0.006599549 0 0.0)

    (benchmark-run 10000 (gnus-delete-duplicates '(a c b c c a d)))
    => (0.0034537929999999997 0 0.0)

Could we improve the performance of `seq-uniq' for lists?

PS. `gnus-delete-duplicates' was recently removed but looks like this:

    (defun gnus-delete-duplicates (list)
      "Remove duplicate entries from LIST."
      (let ((result nil))
        (while list
          (unless (member (car list) result)
    	(push (car list) result))
          (pop list))
        (nreverse result)))