summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2011-02-28 17:34:12 -0500
committerStuart Halloway <stu@thinkrelevance.com>2011-03-02 07:36:16 -0500
commit1aeb592afc0059c8d66a635699c460f70b81a102 (patch)
tree706eff1cf28c898b01c4edd6f3ee2f11a92ec6db
parent0983c8a1eef1e2357f5b2eb307ec777f59001966 (diff)
#748: fast, no alloc path for diffing equal objects
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r--src/clj/clojure/data.clj9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/clj/clojure/data.clj b/src/clj/clojure/data.clj
index 15878962..6e8dbcf2 100644
--- a/src/clj/clojure/data.clj
+++ b/src/clj/clojure/data.clj
@@ -106,6 +106,7 @@
[things-only-in-a things-only-in-b things-in-both].
Comparison rules:
+ * For equal a and b, return [nil nil a].
* Maps are subdiffed where keys match and values differ.
* Sets are never subdiffed.
* All sequential things are treated as associative collections
@@ -114,7 +115,9 @@
an atom and compared for equality."
{:added "1.3"}
[a b]
- (if (= (equality-partition a) (equality-partition b))
- (diff-similar a b)
- (atom-diff a b)))
+ (if (= a b)
+ [nil nil a]
+ (if (= (equality-partition a) (equality-partition b))
+ (diff-similar a b)
+ (atom-diff a b))))