diff --git a/src/reagent/impl/component.cljs b/src/reagent/impl/component.cljs index 107218c..9e871d2 100644 --- a/src/reagent/impl/component.cljs +++ b/src/reagent/impl/component.cljs @@ -133,7 +133,7 @@ (def obligatory {:shouldComponentUpdate nil :componentWillUnmount nil}) -(def dash-to-camel (memoize util/dash-to-camel)) +(def dash-to-camel (util/memoize-1 util/dash-to-camel)) (defn camelify-map-keys [fun-map] (reduce-kv (fn [m k v] diff --git a/src/reagent/impl/template.cljs b/src/reagent/impl/template.cljs index 728a8a2..e9c9fb6 100644 --- a/src/reagent/impl/template.cljs +++ b/src/reagent/impl/template.cljs @@ -22,16 +22,6 @@ ;;; Common utilities -(defn memoize-1 [f] - (let [mem (atom {})] - (fn [arg] - (let [v (get @mem arg)] - (if-not (nil? v) - v - (let [ret (f arg)] - (swap! mem assoc arg ret) - ret)))))) - (defn hiccup-tag? [x] (or (keyword? x) (symbol? x) @@ -56,8 +46,8 @@ ;;; Props conversion -(def cached-prop-name (memoize-1 undash-prop-name)) -(def cached-style-name (memoize-1 util/dash-to-camel)) +(def cached-prop-name (util/memoize-1 undash-prop-name)) +(def cached-style-name (util/memoize-1 util/dash-to-camel)) (defn convert-prop-value [val] (if (map? val) @@ -185,7 +175,7 @@ (let [[comp id-class] (parse-tag tag)] (wrap-component comp id-class (str tag)))) -(def cached-wrapper (memoize-1 get-wrapper)) +(def cached-wrapper (util/memoize-1 get-wrapper)) (declare create-class) diff --git a/src/reagent/impl/util.cljs b/src/reagent/impl/util.cljs index aa99134..73c3c73 100644 --- a/src/reagent/impl/util.cljs +++ b/src/reagent/impl/util.cljs @@ -42,6 +42,16 @@ ;; Misc utilities +(defn memoize-1 [f] + (let [mem (atom {})] + (fn [arg] + (let [v (get @mem arg)] + (if-not (nil? v) + v + (let [ret (f arg)] + (swap! mem assoc arg ret) + ret)))))) + (def dont-camel-case #{"aria" "data"}) (defn capitalize [s]