Skip to content

Commit 0072c67

Browse files
committed
Remove unnecessary laziness
Currently if analyze-causes throws an exception, the stacktrace makes it hard to identify the cause. Compute results eagerly so the offending caller can be tracked down.
1 parent 6547df4 commit 0072c67

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/cider/nrepl/middleware/stacktrace.clj

+7-7
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,14 @@
163163
"Where a parent and child frame represent substantially the same source
164164
location, flag the parent as a duplicate."
165165
[frames]
166-
(cons (first frames)
167-
(map (fn [frame child]
166+
(into [(first frames)]
167+
(map (fn [[frame child]]
168168
(if (or (= (:name frame) (:name child))
169169
(and (= (:file frame) (:file child))
170170
(= (:line frame) (:line child))))
171171
(flag-frame frame :dup)
172-
frame))
173-
(rest frames)
174-
frames)))
172+
frame)))
173+
(map vector (rest frames) frames)))
175174

176175
(defn analyze-frame
177176
"Return the stacktrace as a sequence of maps, each describing a stack frame."
@@ -310,8 +309,9 @@
310309
[e pprint-fn print-options]
311310
(->> e
312311
(iterate #(.getCause ^Exception %))
313-
(take-while identity)
314-
(map (comp extract-location #(analyze-cause % pprint-fn print-options)))))
312+
(into [] (comp (take-while identity)
313+
(map extract-location)
314+
(map #(analyze-cause % pprint-fn print-options))))))
315315

316316
;;; ## Middleware
317317

0 commit comments

Comments
 (0)