Don't retain heads in side-effectful iterations
Replace forms iterating over collections for the purpose of side-effects with alternatives which don't retain heads of collections.
This commit is contained in:
parent
7c9ccb2f3f
commit
e278ce9f39
1 changed files with 7 additions and 9 deletions
|
|
@ -119,8 +119,7 @@
|
|||
(let [done (atom [])]
|
||||
(->> states
|
||||
(sort-by (comp :order meta) order)
|
||||
(map #(fun % (meta %) done))
|
||||
doall)
|
||||
(run! #(fun % (meta %) done)))
|
||||
@done))
|
||||
|
||||
(defn- merge-lifecycles
|
||||
|
|
@ -160,17 +159,17 @@
|
|||
|
||||
(defn stop [& states]
|
||||
(let [states (or states (find-all-states))
|
||||
_ (doall (map unsub states)) ;; unmark substitutions marked by "start-with"
|
||||
_ (run! unsub states) ;; unmark substitutions marked by "start-with"
|
||||
stopped (bring states down >)]
|
||||
(doall (map rollback! states)) ;; restore to origin from "start-with"
|
||||
(run! rollback! states) ;; restore to origin from "start-with"
|
||||
{:stopped stopped}))
|
||||
|
||||
(defn stop-except [& states]
|
||||
(let [all (set (find-all-states))
|
||||
states (remove (set states) all)
|
||||
_ (doall (map unsub states)) ;; unmark substitutions marked by "start-with"
|
||||
_ (run! unsub states) ;; unmark substitutions marked by "start-with"
|
||||
stopped (bring states down >)]
|
||||
(doall (map rollback! states)) ;; restore to origin from "start-with"
|
||||
(run! rollback! states) ;; restore to origin from "start-with"
|
||||
{:stopped stopped}))
|
||||
|
||||
(defn start-with-args [xs & states]
|
||||
|
|
@ -180,9 +179,8 @@
|
|||
(start)))
|
||||
|
||||
(defn start-with [with]
|
||||
(doall
|
||||
(for [[from to] with]
|
||||
(substitute! from to)))
|
||||
(doseq [[from to] with]
|
||||
(substitute! from to))
|
||||
(start))
|
||||
|
||||
(defn start-without [& states]
|
||||
|
|
|
|||
Loading…
Reference in a new issue