From 1aeb592afc0059c8d66a635699c460f70b81a102 Mon Sep 17 00:00:00 2001 From: Stuart Halloway Date: Mon, 28 Feb 2011 17:34:12 -0500 Subject: #748: fast, no alloc path for diffing equal objects Signed-off-by: Stuart Halloway --- src/clj/clojure/data.clj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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)))) -- cgit v1.2.3-70-g09d2