migrate small check outside write-bytes body
This commit is contained in:
parent
e8edba1493
commit
140171393c
1 changed files with 5 additions and 5 deletions
|
|
@ -163,13 +163,13 @@
|
||||||
(defmacro write-id [out id] `(.writeByte ~out ~id))
|
(defmacro write-id [out id] `(.writeByte ~out ~id))
|
||||||
(defmacro write-bytes [out ba & [small?]]
|
(defmacro write-bytes [out ba & [small?]]
|
||||||
(let [out (with-meta out {:tag 'java.io.DataOutput})
|
(let [out (with-meta out {:tag 'java.io.DataOutput})
|
||||||
ba (with-meta ba {:tag 'bytes})]
|
ba (with-meta ba {:tag 'bytes})
|
||||||
|
;; Optimization, must be known before id's written
|
||||||
|
;; `byte` to throw on range error
|
||||||
|
[wc wr] (if small? [byte 'writeByte] [int 'writeInt])]
|
||||||
`(let [out# ~out, ba# ~ba
|
`(let [out# ~out, ba# ~ba
|
||||||
size# (alength ba#)]
|
size# (alength ba#)]
|
||||||
(if ~small? ; Optimization, must be known before id's written
|
(. out# ~wr (~wc size#))
|
||||||
(.writeByte out# (byte size#)) ; `byte` to throw on range error
|
|
||||||
(.writeInt out# (int size#)) ; `int` ''
|
|
||||||
)
|
|
||||||
(.write out# ba# 0 size#))))
|
(.write out# ba# 0 size#))))
|
||||||
|
|
||||||
(defmacro write-biginteger [out x]
|
(defmacro write-biginteger [out x]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue