Skip to content

Commit f8c6a9a

Browse files
authored
Merge pull request #1125 from frenchy64/issue-1124-pointer-identity
Close #1124: only assume string interning in cljs
2 parents 0680cdd + 4a6e081 commit f8c6a9a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/malli/core.cljc

+4-2
Original file line numberDiff line numberDiff line change
@@ -2724,8 +2724,10 @@
27242724
(merge (predicate-schemas) (class-schemas) (comparator-schemas) (type-schemas) (sequence-schemas) (base-schemas)))
27252725

27262726
(def default-registry
2727-
(let [strict (identical? mr/mode "strict")
2728-
custom (identical? mr/type "custom")
2727+
(let [strict #?(:cljs (identical? mr/mode "strict")
2728+
:default (= mr/mode "strict"))
2729+
custom #?(:cljs (identical? mr/type "custom")
2730+
:default (= mr/type "custom"))
27292731
registry (if custom (mr/fast-registry {}) (mr/composite-registry (mr/fast-registry (default-schemas)) (mr/var-registry)))]
27302732
(when-not strict (mr/set-default-registry! registry))
27312733
(mr/registry (if strict registry (mr/custom-default-registry)))))

src/malli/registry.cljc

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#?(:clj (:import (java.util HashMap Map))))
44

55
#?(:cljs (goog-define mode "default")
6-
:clj (def mode (as-> (or (System/getProperty "malli.registry/mode") "default") $ (.intern $))))
6+
:clj (def mode (or (System/getProperty "malli.registry/mode") "default")))
77

88
#?(:cljs (goog-define type "default")
9-
:clj (def type (as-> (or (System/getProperty "malli.registry/type") "default") $ (.intern $))))
9+
:clj (def type (or (System/getProperty "malli.registry/type") "default")))
1010

1111
(defprotocol Registry
1212
(-schema [this type] "returns the schema from a registry")
@@ -40,7 +40,8 @@
4040
(def ^:private registry* (atom (simple-registry {})))
4141

4242
(defn set-default-registry! [?registry]
43-
(if-not (identical? mode "strict")
43+
(if-not #?(:cljs (identical? mode "strict")
44+
:default (= mode "strict"))
4445
(reset! registry* (registry ?registry))
4546
(throw (ex-info "can't set default registry, invalid mode" {:mode mode, :type type}))))
4647

0 commit comments

Comments
 (0)