diff --git a/project.clj b/project.clj index 0bbe7aa..5cf7deb 100644 --- a/project.clj +++ b/project.clj @@ -15,7 +15,7 @@ :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/tools.reader "0.10.0"] - [com.taoensso/encore "2.36.2"] + [com.taoensso/encore "2.41.0"] [org.iq80.snappy/snappy "0.4"] [org.tukaani/xz "1.5"] [net.jpountz.lz4/lz4 "1.3"]] diff --git a/src/taoensso/nippy.clj b/src/taoensso/nippy.clj index f0fa701..b6404e7 100644 --- a/src/taoensso/nippy.clj +++ b/src/taoensso/nippy.clj @@ -19,8 +19,8 @@ IRecord ISeq])) (if (vector? enc/encore-version) - (enc/assert-min-encore-version [2 16 0]) - (enc/assert-min-encore-version 2.16)) + (enc/assert-min-encore-version [2 41 0]) + (enc/assert-min-encore-version 2.41)) ;;;; Nippy data format ;; * 4-byte header (Nippy v2.x+) (may be disabled but incl. by default) [1] @@ -473,23 +473,28 @@ (defn read-utf8 ^String [^DataInput in] (String. (read-bytes in) "UTF-8")) (defn read-sm-utf8 ^String [^DataInput in] (String. (read-sm-bytes in) "UTF-8")) -(defn read-coll [^DataInput in to-coll] - (enc/repeatedly-into to-coll (.readInt in) (fn [] (thaw-from-in! in)))) +(defn- -read-coll [^DataInput in to-coll ^long n] + (if (and (> n 10) (enc/editable? to-coll)) + (persistent! + (enc/reduce-n (fn [acc _] (conj! acc (thaw-from-in! in))) + (transient to-coll) n)) -(defn read-sm-coll [^DataInput in to-coll] - (enc/repeatedly-into to-coll (.readByte in) (fn [] (thaw-from-in! in)))) + (enc/reduce-n (fn [acc _] (conj acc (thaw-from-in! in))) to-coll n))) -(defn read-kvs [^DataInput in to-coll] - (enc/repeatedly-into to-coll (.readInt in) - (fn [] [(thaw-from-in! in) (thaw-from-in! in)]))) +(defn- -read-kvs [^DataInput in to-coll ^long n] + (if (and (> n 10) (enc/editable? to-coll)) + (persistent! + (enc/reduce-n (fn [acc _] (assoc! acc (thaw-from-in! in) (thaw-from-in! in))) + (transient to-coll) n)) -(defn read-sm-kvs [^DataInput in to-coll] - (enc/repeatedly-into to-coll (.readByte in) - (fn [] [(thaw-from-in! in) (thaw-from-in! in)]))) + (enc/reduce-n (fn [acc _] (assoc acc (thaw-from-in! in) (thaw-from-in! in))) + to-coll n))) -(defn read-kvs-depr1 [^DataInput in to-coll] - (enc/repeatedly-into to-coll (quot (.readInt in) 2) - (fn [] [(thaw-from-in! in) (thaw-from-in! in)]))) +(defn read-coll [^DataInput in to-coll] (-read-coll in to-coll (.readInt in))) +(defn read-sm-coll [^DataInput in to-coll] (-read-coll in to-coll (.readByte in))) +(defn read-kvs [^DataInput in to-coll] (-read-kvs in to-coll (.readInt in))) +(defn read-sm-kvs [^DataInput in to-coll] (-read-kvs in to-coll (.readByte in))) +(defn read-kvs-depr1 [^DataInput in to-coll] (-read-kvs in to-coll (quot (.readInt in) 2))) (def ^:private class-method-sig (into-array Class [IPersistentMap]))