You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make things snappier by inlining all the public-api functions like this (would emit same amount of code - a good candidate for inlining):
(defnwrite-value-as-string"Encode a value as a JSON string. To configure, pass in an ObjectMapper created with [[object-mapper]]."
([object]
(.writeValueAsString +default-mapper+ object))
([object ^ObjectMapper mapper]
(.writeValueAsString mapper object)))
example of inlining from clojure.core:
(defn="Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) as a value, not an identity, comparison."
{:inline (fn [x y] `(. clojure.lang.Util equiv ~x ~y))
:inline-arities #{2}
:added"1.0"}
([x] true)
([x y] (clojure.lang.Util/equiv x y))
([x y & more]
(if (clojure.lang.Util/equiv x y)
(if (next more)
(recur y (first more) (next more))
(clojure.lang.Util/equiv y (first more)))
false)))
The text was updated successfully, but these errors were encountered:
Not sure if you want to go this route, but Zach Tellman has some definline code somewhere that lets you write this kind of code once, rather than copying it between the function definitions and the inline definitions.
Thanks for the tip! there is also definline in the clojure.core. Just run a set of perf tests with hand written inlining for write-value-as-string and there is no notable difference in performance. +-1ns. So, no inlining for now.
Make things snappier by inlining all the public-api functions like this (would emit same amount of code - a good candidate for inlining):
example of inlining from
clojure.core
:The text was updated successfully, but these errors were encountered: