mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +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 start]
|
||||
(loop [idx start
|
||||
items items
|
||||
items (seq items)
|
||||
res (transient [])]
|
||||
(if (empty? items)
|
||||
(persistent! res)
|
||||
(if items
|
||||
(recur (inc idx)
|
||||
(rest items)
|
||||
(conj! res [idx (first items)]))))))
|
||||
(next items)
|
||||
(conj! res [idx (first items)]))
|
||||
(persistent! res)))))
|
||||
|
||||
(defn group-by
|
||||
([kf coll] (group-by kf identity [] coll))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user