Skip to content

Commit 54ce94e

Browse files
committed
make constants more optimal in runtime
1 parent d037d41 commit 54ce94e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src-clj/libmisc_clj/vars.clj

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
(ns libmisc-clj.vars)
22

3-
(defonce ^:static ttl_1m (* 1000 60)) ;seconds @ minute
4-
(defonce ^:static ttl_1h (* ttl_1m 60)) ;mins @ hour
5-
(defonce ^:static ttl_1d (* ttl_1h 24)) ;day
6-
(defonce ^:static ttl_1w (* ttl_1d 7)) ;week
3+
(defonce ^:const ^:static ttl_1m (* 1000 60)) ;seconds @ minute
4+
(defonce ^:const ^:static ttl_1h (* ttl_1m 60)) ;mins @ hour
5+
(defonce ^:const ^:static ttl_1d (* ttl_1h 24)) ;day
6+
(defonce ^:const ^:static ttl_1w (* ttl_1d 7)) ;week
7+
8+
(def ^:const ^:static time-units-ms
9+
(apply hash-map
10+
(interleave [:millisecond :second :minute :hour :day :week]
11+
(reductions * [1 1000 60 60 24 7]))))

0 commit comments

Comments
 (0)