File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
1
(ns orchard.misc
2
2
; ; These will be added in clojure 1.11:
3
- (:refer-clojure :exclude [update-keys update-vals])
3
+ (:refer-clojure :exclude [update-keys update-vals pmap ])
4
4
(:require
5
5
[clojure.java.io :as io]
6
6
[clojure.string :as str]
161
161
(fn [& args]
162
162
(when resolved-fn
163
163
(apply resolved-fn args)))))
164
+
165
+ (defn- into! [transient-coll1 transient-coll2]
166
+ (reduce conj! transient-coll1 (persistent! transient-coll2)))
167
+
168
+ (defn pmap
169
+ " Like `clojure.core/pmap`, but uses parallel streams for better efficiency."
170
+ [f, ^java.util.Collection coll]
171
+ (-> (.parallelStream coll)
172
+ (.map (reify java.util.function.Function
173
+ (apply [_ x] (f x))))
174
+ (.collect (reify java.util.function.Supplier
175
+ (get [_] (volatile! (transient []))))
176
+ (reify java.util.function.BiConsumer
177
+ (accept [_ acc x] (vswap! acc conj! x)))
178
+ (reify java.util.function.BiConsumer
179
+ (accept [_ acc1 acc2]
180
+ (vswap! acc1 into! @acc2))))
181
+ deref
182
+ persistent!))
Original file line number Diff line number Diff line change 12
12
[clojure.string :as str]
13
13
[orchard.info :as info]
14
14
[orchard.java.resource :as resource]
15
- [orchard.misc :refer [assoc-some]])
15
+ [orchard.misc :as misc : refer [assoc-some]])
16
16
(:import
17
17
(java.io StringWriter)
18
18
(java.net URL)
252
252
" Return the stacktrace as a sequence of maps, each describing a stack frame."
253
253
[trace]
254
254
(when (seq trace)
255
- (-> (pmap analyze-frame trace)
255
+ (-> (misc/ pmap analyze-frame trace)
256
256
(flag-duplicates )
257
257
(flag-tooling ))))
258
258
You can’t perform that action at this time.
0 commit comments