Perf: fix boxed math on long compression
This commit is contained in:
parent
d89649deeb
commit
56b33e23f0
1 changed files with 14 additions and 12 deletions
|
|
@ -286,17 +286,18 @@
|
||||||
(extend-type Long ; Optimized common-case type
|
(extend-type Long ; Optimized common-case type
|
||||||
Freezable
|
Freezable
|
||||||
(freeze-to-out* [x ^DataOutput out]
|
(freeze-to-out* [x ^DataOutput out]
|
||||||
|
(let [^long x x]
|
||||||
(cond
|
(cond
|
||||||
(<= Byte/MIN_VALUE x Byte/MAX_VALUE)
|
(and (<= Byte/MIN_VALUE x) (<= x Byte/MAX_VALUE))
|
||||||
(do (write-id out id-byte-as-long) (.writeByte out x))
|
(do (write-id out id-byte-as-long) (.writeByte out x))
|
||||||
|
|
||||||
(<= Short/MIN_VALUE x Short/MAX_VALUE)
|
(and (<= Short/MIN_VALUE x) (<= x Short/MAX_VALUE))
|
||||||
(do (write-id out id-short-as-long) (.writeShort out x))
|
(do (write-id out id-short-as-long) (.writeShort out x))
|
||||||
|
|
||||||
(<= Integer/MIN_VALUE x Integer/MAX_VALUE)
|
(and (<= Integer/MIN_VALUE x) (<= x Integer/MAX_VALUE))
|
||||||
(do (write-id out id-int-as-long) (.writeInt out 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))))))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
@ -361,6 +362,7 @@
|
||||||
|
|
||||||
(defn- wrap-header [data-ba head-meta]
|
(defn- wrap-header [data-ba head-meta]
|
||||||
(if-let [head-ba (get-head-ba head-meta)]
|
(if-let [head-ba (get-head-ba head-meta)]
|
||||||
|
;; TODO Would be nice if we could avoid the array copy here:
|
||||||
(encore/ba-concat head-ba data-ba)
|
(encore/ba-concat head-ba data-ba)
|
||||||
(throw (ex-info (format "Unrecognized header meta: %s" head-meta)
|
(throw (ex-info (format "Unrecognized header meta: %s" head-meta)
|
||||||
{:head-meta head-meta}))))
|
{:head-meta head-meta}))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue