From d61fb06f3ba02cfbfbf177bc366832dbf23bf0b5 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 29 Sep 2015 20:05:41 +0700 Subject: [PATCH] Primitive ided-long checks --- src/taoensso/nippy.clj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/taoensso/nippy.clj b/src/taoensso/nippy.clj index d02293b..f0f9d77 100644 --- a/src/taoensso/nippy.clj +++ b/src/taoensso/nippy.clj @@ -190,15 +190,18 @@ (defn write-ided-long [^DataOutput out ^long n] (cond - (and (<= n Byte/MAX_VALUE) (<= Byte/MIN_VALUE n)) + (and (<= n 127 #_Byte/MAX_VALUE) + (<= -128 #_Byte/MIN_VALUE n)) (do (write-id out id-byte-as-long) (.writeByte out n)) - (and (<= n Short/MAX_VALUE) (<= Short/MIN_VALUE n)) + (and (<= n 32767 #_Short/MAX_VALUE) + (<= -32768 #_Short/MIN_VALUE n)) (do (write-id out id-short-as-long) (.writeShort out n)) - (and (<= n Integer/MAX_VALUE) (<= Integer/MIN_VALUE n)) + (and (<= n 2147483647 #_Integer/MAX_VALUE) + (<= -2147483648 #_Integer/MIN_VALUE n)) (do (write-id out id-int-as-long) (.writeInt out n))