From 956ce7df7ec7ae8b2da5de3093173b40d79839e5 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Mon, 28 Sep 2015 10:21:15 +0700 Subject: [PATCH] Micro optimization: `read-bytes` expansion --- src/taoensso/nippy.clj | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/taoensso/nippy.clj b/src/taoensso/nippy.clj index 92f4809..08dee69 100644 --- a/src/taoensso/nippy.clj +++ b/src/taoensso/nippy.clj @@ -435,12 +435,17 @@ (declare thaw-from-in) (defmacro read-bytes [in & [small?]] - `(let [in# ~in - size# (if ~small? ; Optimization, must be known before id's written - (.readByte in#) - (.readInt in#)) - ba# (byte-array size#)] - (.readFully in# ba# 0 size#) ba#)) + (if small? ; Optimization, must be known before id's written + `(let [in# ~in + size# (.readByte in#) + ba# (byte-array size#)] + (.readFully in# ba# 0 size#) + ba#) + `(let [in# ~in + size# (.readInt in#) + ba# (byte-array size#)] + (.readFully in# ba# 0 size#) + ba#))) (defmacro read-biginteger [in] `(BigInteger. (read-bytes ~in))) (defmacro read-utf8 [in & [small?]]