Skip to content

Commit 7ab4f2e

Browse files
committed
[fix] Msgpack clj->cljs safe uint64 compatibility
1 parent d7db432 commit 7ab4f2e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/taoensso/msgpack/impl.clj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@
5050
)
5151

5252
(cond
53-
(<= n 127) (.writeByte out n) ; +fixnum
54-
(<= n 0xff) (do (.writeByte out 0xcc) (.writeByte out n)) ; uint8
55-
(<= n 0xffff) (do (.writeByte out 0xcd) (.writeShort out n)) ; uint16
56-
(<= n 0xffffffff) (do (.writeByte out 0xce) (.writeInt out (unchecked-int n))) ; uint32
57-
:else (do (.writeByte out 0xcf) (.writeLong out (unchecked-long n))) ; uint64
53+
(<= n 127) (.writeByte out n) ; +fixnum
54+
(<= n 0xff) (do (.writeByte out 0xcc) (.writeByte out n)) ; uint8
55+
(<= n 0xffff) (do (.writeByte out 0xcd) (.writeShort out n)) ; uint16
56+
(<= n 0xffffffff) (do (.writeByte out 0xce) (.writeInt out (unchecked-int n))) ; uint32
57+
(<= n 0x7fffffffffffffff) (do (.writeByte out 0xd3) (.writeLong out n)) ; int64 if possible
58+
:else (do (.writeByte out 0xcf) (.writeLong out (unchecked-long n))) ; uint64
5859
)))
5960

6061
(defn- pack-coll [c ^DataOutput out] (reduce (fn [_ el] (pack-bytes el out)) nil c))

0 commit comments

Comments
 (0)