From d3120f02468c6cd29f78551a4da3af7cfe56b95b Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Wed, 7 Aug 2013 17:52:00 +0700 Subject: [PATCH] Remove :print-dup? option (no longer useful since switch to edn/read-string) --- src/taoensso/nippy.clj | 23 ++++++++--------------- src/taoensso/nippy/benchmarks.clj | 2 +- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/taoensso/nippy.clj b/src/taoensso/nippy.clj index f2969b8..90720dc 100644 --- a/src/taoensso/nippy.clj +++ b/src/taoensso/nippy.clj @@ -33,7 +33,7 @@ (def ^:const id-bytes (int 2)) (def ^:const id-nil (int 3)) (def ^:const id-boolean (int 4)) -(def ^:const id-reader (int 5)) ; Fallback: *print-dup* pr-str output +(def ^:const id-reader (int 5)) ; Fallback: pr-str output (def ^:const id-char (int 10)) ;; 11 @@ -98,12 +98,8 @@ (defn freeze-to-stream! "Low-level API. Serializes arg (any Clojure data type) to a DataOutputStream." - [^DataOutputStream data-output-stream x & [{:keys [print-dup?] - :or {print-dup? true}}]] - (if (identical? *print-dup* print-dup?) - (freeze-to-stream data-output-stream x) - (binding [*print-dup* print-dup?] ; Expensive - (freeze-to-stream data-output-stream x)))) + [^DataOutputStream data-output-stream x & _] + (freeze-to-stream data-output-stream x)) (defmacro ^:private freezer "Helper to extend Freezable protocol." @@ -196,14 +192,13 @@ "Serializes arg (any Clojure data type) to a byte array. Set :legacy-mode to true to produce bytes readble by Nippy < 2.x. For custom types extend the Clojure reader or see `extend-freeze`." - ^bytes [x & [{:keys [print-dup? password compressor encryptor legacy-mode] - :or {print-dup? true - compressor snappy-compressor + ^bytes [x & [{:keys [password compressor encryptor legacy-mode] + :or {compressor snappy-compressor encryptor aes128-encryptor}}]] (when legacy-mode (assert-legacy-args compressor password)) (let [ba (ByteArrayOutputStream.) stream (DataOutputStream. ba)] - (freeze-to-stream! stream x {:print-dup? print-dup?}) + (freeze-to-stream! stream x) (let [ba (.toByteArray ba) ba (if compressor (compression/compress compressor ba) ba) ba (if password (encryption/encrypt encryptor password ba) ba)] @@ -468,11 +463,9 @@ (throw (AssertionError. "Only Snappy compressor supported in legacy mode.")))) (defn freeze-to-bytes "DEPRECATED: Use `freeze` instead." - ^bytes [x & {:keys [print-dup? compress?] - :or {print-dup? true - compress? true}}] + ^bytes [x & {:keys [compress?] + :or {compress? true}}] (freeze x {:legacy-mode true - :print-dup? print-dup? :compressor (when compress? snappy-compressor) :password nil})) diff --git a/src/taoensso/nippy/benchmarks.clj b/src/taoensso/nippy/benchmarks.clj index 9abdf91..0f6acce 100644 --- a/src/taoensso/nippy/benchmarks.clj +++ b/src/taoensso/nippy/benchmarks.clj @@ -9,7 +9,7 @@ (defmacro bench* [& body] `(utils/bench 10000 (do ~@body) :warmup-laps 2000)) -(defn freeze-reader [x] (binding [*print-dup* false] (pr-str x))) +(defn freeze-reader [x] (pr-str x)) (defn thaw-reader [x] (edn/read-string x)) (def roundtrip-reader (comp thaw-reader freeze-reader))