Skip to content

Commit 5a3c15a

Browse files
committed
Revert "Only enable within-string diffing when selected."
This reverts commit 6d28880.
1 parent 6d28880 commit 5a3c15a

1 file changed

Lines changed: 14 additions & 32 deletions

File tree

src/lambdaisland/deep_diff2/diff_impl.cljc

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,6 @@
9797
(diff-seq-insertions ins)
9898
(into []))))
9999

100-
(defn diff-string [exp act]
101-
(->> (diff-seq exp act)
102-
(map #(if (char? %) {:= %} %))
103-
(partition-by (comp first keys))
104-
(map (fn [[first-element :as coll]]
105-
(let [head (first (keys first-element))
106-
contents (mapcat vals coll)]
107-
{head (apply str contents) })
108-
)))
109-
)
110-
111100
(defn diff-set [exp act]
112101
(into
113102
(into #{}
@@ -142,7 +131,7 @@
142131
exp-ks))))
143132

144133
(defn primitive? [x]
145-
(or (number? x) (boolean? x) (inst? x) (keyword? x) (symbol? x)))
134+
(or (number? x) (string? x) (boolean? x) (inst? x) (keyword? x) (symbol? x)))
146135

147136
(defn diff-atom [exp act]
148137
(if (= exp act)
@@ -162,30 +151,23 @@
162151
(defn array? [x]
163152
(and x (.isArray (class x)))))
164153

165-
(defn diff
166-
([exp act]
167-
(diff exp act {}))
168-
([exp act {:keys [diff-strings?] :as _opts}]
169-
(cond
170-
(nil? exp)
171-
(diff-atom exp act)
172-
173-
(and (diffable? exp)
174-
(= (data/equality-partition exp) (data/equality-partition act)))
175-
(diff-similar exp act)
154+
(defn diff [exp act]
155+
(cond
156+
(nil? exp)
157+
(diff-atom exp act)
176158

177-
(array? exp)
178-
(diff-seq exp act)
159+
(and (diffable? exp)
160+
(= (data/equality-partition exp) (data/equality-partition act)))
161+
(diff-similar exp act)
179162

180-
(record? exp)
181-
(diff-map exp act)
163+
(array? exp)
164+
(diff-seq exp act)
182165

183-
(and diff-strings?
184-
(string? exp))
185-
(diff-string exp act)
166+
(record? exp)
167+
(diff-map exp act)
186168

187-
:else
188-
(diff-atom exp act))))
169+
:else
170+
(diff-atom exp act)))
189171

190172
(extend-protocol Diff
191173
#?(:clj java.util.Set :cljs cljs.core/PersistentHashSet)

0 commit comments

Comments
 (0)