Improve performance of seq-union
* lisp/emacs-lisp/seq.el (seq-union): Improve performance by using nreverse instead of seq-reverse.
This commit is contained in:
parent
0bdd6488fc
commit
3e5298fc96
1 changed files with 7 additions and 7 deletions
|
@ -471,13 +471,13 @@ negative integer or 0, nil is returned."
|
|||
(cl-defgeneric seq-union (sequence1 sequence2 &optional testfn)
|
||||
"Return a list of all elements that appear in either SEQUENCE1 or SEQUENCE2.
|
||||
Equality is defined by TESTFN if non-nil or by `equal' if nil."
|
||||
(let ((accum (lambda (acc elt)
|
||||
(if (seq-contains-p acc elt testfn)
|
||||
acc
|
||||
(cons elt acc)))))
|
||||
(seq-reverse
|
||||
(seq-reduce accum sequence2
|
||||
(seq-reduce accum sequence1 '())))))
|
||||
(let* ((accum (lambda (acc elt)
|
||||
(if (seq-contains-p acc elt testfn)
|
||||
acc
|
||||
(cons elt acc))))
|
||||
(result (seq-reduce accum sequence2
|
||||
(seq-reduce accum sequence1 '()))))
|
||||
(nreverse result)))
|
||||
|
||||
;;;###autoload
|
||||
(cl-defgeneric seq-intersection (sequence1 sequence2 &optional testfn)
|
||||
|
|
Loading…
Add table
Reference in a new issue