mirror of
https://github.com/penpot/penpot.git
synced 2026-05-26 02:13:46 +00:00
⚡ Use seq/next idiom in enumerate instead of empty?/rest
Replace (empty? items) + (rest items) with (seq items) + (next items) in enumerate. The seq/next pattern is idiomatic Clojure and avoids the overhead of empty? which internally calls seq and then negates.
This commit is contained in:
parent
92dd5d9954
commit
1cc860807e
@ -252,13 +252,13 @@
|
|||||||
([items] (enumerate items 0))
|
([items] (enumerate items 0))
|
||||||
([items start]
|
([items start]
|
||||||
(loop [idx start
|
(loop [idx start
|
||||||
items items
|
items (seq items)
|
||||||
res (transient [])]
|
res (transient [])]
|
||||||
(if (empty? items)
|
(if items
|
||||||
(persistent! res)
|
|
||||||
(recur (inc idx)
|
(recur (inc idx)
|
||||||
(rest items)
|
(next items)
|
||||||
(conj! res [idx (first items)]))))))
|
(conj! res [idx (first items)]))
|
||||||
|
(persistent! res)))))
|
||||||
|
|
||||||
(defn group-by
|
(defn group-by
|
||||||
([kf coll] (group-by kf identity [] coll))
|
([kf coll] (group-by kf identity [] coll))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user