Skip to content

Commit 1efce29

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 cf3d1d4 commit 1efce29

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/cider/nrepl/middleware/stacktrace.clj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,14 @@
162162
"Where a parent and child frame represent substantially the same source
163163
location, flag the parent as a duplicate."
164164
[frames]
165-
(cons (first frames)
166-
(map (fn [frame child]
165+
(into [(first frames)]
166+
(map (fn [[frame child]]
167167
(if (or (= (:name frame) (:name child))
168168
(and (= (:file frame) (:file child))
169169
(= (:line frame) (:line child))))
170170
(flag-frame frame :dup)
171-
frame))
172-
(rest frames)
173-
frames)))
171+
frame)))
172+
(mapv vector (rest frames) frames)))
174173

175174
(defn analyze-frame
176175
"Return the stacktrace as a sequence of maps, each describing a stack frame."
@@ -308,8 +307,9 @@
308307
[e pprint-fn print-options]
309308
(->> e
310309
(iterate #(.getCause ^Exception %))
311-
(take-while identity)
312-
(map (comp extract-location #(analyze-cause % pprint-fn print-options)))))
310+
(into [] (comp (take-while identity)
311+
(map #(analyze-cause % pprint-fn print-options))
312+
(map extract-location)))))
313313

314314
;;; ## Middleware
315315

0 commit comments

Comments
 (0)