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 11(ns orchard.misc
22 ; ; 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 ])
44 (:require
55 [clojure.java.io :as io]
66 [clojure.string :as str]
161161 (fn [& args]
162162 (when resolved-fn
163163 (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 1212 [clojure.string :as str]
1313 [orchard.info :as info]
1414 [orchard.java.resource :as resource]
15- [orchard.misc :refer [assoc-some]])
15+ [orchard.misc :as misc : refer [assoc-some]])
1616 (:import
1717 (java.io StringWriter)
1818 (java.net URL)
252252 " Return the stacktrace as a sequence of maps, each describing a stack frame."
253253 [trace]
254254 (when (seq trace)
255- (-> (pmap analyze-frame trace)
255+ (-> (misc/ pmap analyze-frame trace)
256256 (flag-duplicates )
257257 (flag-tooling ))))
258258
You can’t perform that action at this time.
0 commit comments