Enabled by default | Version Added | Version Updated |
---|---|---|
false | 1.10.0 | 1.10.0 |
Assoc takes multiple pairs but relies on seq
stepping. This is slower than
relying on multiple assoc
invocations.
# bad
(assoc m :k1 1 :k2 2 :k3 3)
# good
(-> m
(assoc :k1 1)
(assoc :k2 2)
(assoc :k3 3))
Enabled by default | Version Added | Version Updated |
---|---|---|
false | 1.10.0 | 1.10.0 |
Avoid use of satisfies?
as it is extremely slow. Restructure your code to rely on protocols or other polymorphic forms.
# bad
(satisfies? Foo :bar)
Enabled by default | Version Added | Version Updated |
---|---|---|
false | 1.10.0 | 1.10.0 |
clojure.core/get-in
is both polymorphic and relies on seq stepping, which has heavy overhead when the listed slots are keyword literals. Faster to call them as functions.
# bad
(get-in m [:some-key1 :some-key2 :some-key3])
# good
(-> m :some-key1 :some-key2 :some-key3)
Enabled by default | Version Added | Version Updated |
---|---|---|
false | 1.10.0 | 1.10.0 |
clojure.core/get
is polymorphic and overkill if accessing a map with a keyword literal. The fastest is to fall the map itself as a function but that requires a nil
check, so the safest fast method is to use the keyword as function.
# bad
(get m :some-key)
# good
(:some-key m)
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close