Optimize compact long freezer

This commit is contained in:
Peter Taoussanis 2015-09-30 11:57:00 +07:00
parent 1506747e42
commit 4765a32e4e

View file

@ -282,16 +282,23 @@
(freeze-to-out* [x ^DataOutput out] (freeze-to-out* [x ^DataOutput out]
(let [^long x x] (let [^long x x]
(cond (cond
(and (<= Byte/MIN_VALUE x) (<= x Byte/MAX_VALUE)) (and (<= x #_Byte/MAX_VALUE 127)
(do (write-id out id-byte-as-long) (.writeByte out x)) (<= #_Byte/MIN_VALUE -128 x))
(do (write-id out id-byte-as-long)
(.writeByte out x))
(and (<= Short/MIN_VALUE x) (<= x Short/MAX_VALUE)) (and (<= x #_Short/MAX_VALUE 32767)
(do (write-id out id-short-as-long) (.writeShort out x)) (<= #_Short/MIN_VALUE -32768 x))
(do (write-id out id-short-as-long)
(.writeShort out x))
(and (<= Integer/MIN_VALUE x) (<= x Integer/MAX_VALUE)) (and (<= x #_Integer/MAX_VALUE 2147483647)
(do (write-id out id-int-as-long) (.writeInt out x)) (<= #_Integer/MIN_VALUE -2147483648 x))
(do (write-id out id-int-as-long)
(.writeInt out x))
:else (do (write-id out id-long) (.writeLong out x)))))) :else (do (write-id out id-long)
(.writeLong out x))))))
;; ;;