Make constants const

This commit is contained in:
Dan Holmsand 2015-09-11 12:35:06 +02:00
parent f785362b46
commit 679136f5d5
2 changed files with 26 additions and 5 deletions

View File

@ -47,7 +47,7 @@
{:compiler {:optimizations :advanced
:elide-asserts true
:pretty-print false
:pseudo-names true
;; :pseudo-names true
:output-dir "target/client"}}}}}]
:prod-test [:test :prod]

View File

@ -202,9 +202,9 @@
(-handle-change [this sender oldval newval])
(-update-watching [this derefed]))
(def clean 0)
(def maybe-dirty 1)
(def dirty 2)
(def ^:const clean 0)
(def ^:const maybe-dirty 1)
(def ^:const dirty 2)
(deftype Reaction [f ^:mutable state ^:mutable ^number dirtyness
^:mutable watching ^:mutable watches
@ -326,7 +326,7 @@
(set! watching nil)
(set! state nil)
(set! dirtyness dirty)
(when on-dispose
(when (some? on-dispose)
(on-dispose)))
IEquiv
@ -419,3 +419,24 @@
(util/partial-ifn. callback-fn args nil)
false nil))
(comment
(def perf-check 0)
(defn ratom-perf []
(dbg "ratom-perf")
(set! debug false)
(dotimes [_ 10]
(set! perf-check 0)
(let [nite 100000
a (atom 0)
mid (make-reaction (fn [] (inc @a)))
res (make-reaction (fn []
(set! perf-check (inc perf-check))
(inc @mid))
:auto-run true)]
@res
(time (dotimes [x nite]
(swap! a inc)))
(dispose! res)
(assert (= perf-check (inc nite))))))
(enable-console-print!)
(ratom-perf))