emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dash 8fa70c5 12/14: [Fix #101] Use faster hashtable imp


From: Phillip Lord
Subject: [elpa] externals/dash 8fa70c5 12/14: [Fix #101] Use faster hashtable implementation for -union.
Date: Sun, 04 Oct 2015 12:01:04 +0000

branch: externals/dash
commit 8fa70c5d078f773057694bd1e917b9e1c084decb
Author: Matus Goljer <address@hidden>
Commit: Matus Goljer <address@hidden>

    [Fix #101] Use faster hashtable implementation for -union.
---
 dash.el |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/dash.el b/dash.el
index 6ecf100..6cd9a24 100644
--- a/dash.el
+++ b/dash.el
@@ -1783,8 +1783,20 @@ Alias: `-uniq'"
   "Return a new list containing the elements of LIST1 and elements of LIST2 
that are not in LIST1.
 The test for equality is done with `equal',
 or with `-compare-fn' if that's non-nil."
-  (let ((result (reverse list)))
-    (--each list2 (unless (-contains? result it) (!cons it result)))
+  ;; We fall back to iteration implementation if the comparison
+  ;; function isn't one of `eq', `eql' or `equal'.
+  (let* ((result (reverse list))
+         ;; TODO: get rid of this dynamic variable, pass it as an
+         ;; argument instead.
+         (-compare-fn (if (bound-and-true-p -compare-fn)
+                          -compare-fn
+                        'equal)))
+    (if (memq -compare-fn '(eq eql equal))
+        (progn
+          (--each list2 (unless (-contains? result it) (!cons it result))))
+      (let ((ht (make-hash-table :test -compare-fn)))
+        (--each list (puthash it it ht ))
+        (--each list2 (unless (gethash it ht) (!cons it result)))))
     (nreverse result)))
 
 (defun -intersection (list list2)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]