This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-26
Channels
- # adventofcode (23)
- # babashka (13)
- # beginners (63)
- # calva (17)
- # circleci (2)
- # cljdoc (3)
- # cljfx (11)
- # clojure (23)
- # clojure-europe (2)
- # clojure-uk (1)
- # conjure (1)
- # depstar (4)
- # emacs (3)
- # fulcro (41)
- # graalvm (29)
- # joker (5)
- # malli (6)
- # reagent (6)
- # reitit (1)
- # remote-jobs (1)
- # shadow-cljs (19)
- # spacemacs (8)
- # testing (9)
- # tools-deps (33)
I’ve started switching out Spec for Malli to improve performance in hot code. it works great except when using recursive schemas. I’ve created a gist to illustrate https://gist.github.com/stevebuik/e4f3475e46dd5ebb1de7707438fa073f
@steveb8n you are using :and
, which composes the two maps - in validation it runs two validations, one for each map. If you use malli.util/merge
, the end result is one schema, and validation runs it just once. tested the first example, it’s 90ns vs 97ns, which is the cost of iterating over 2 MapEntrys instead of just one.
(require '[malli.util :as mu])
(def simple-tree-node
(mu/merge
simple-node
[:map {:registry {::child simple-node}}
[:children {:optional true} [:vector [:ref ::child]]]]))