Browse files

Remove last redundant calls to .read in parser

  • Loading branch information...
1 parent 25d4d28 commit 7b061441189393e68d9a6cce9e9fba8600a3463f @stuartsierra stuartsierra committed Oct 5, 2012
Showing with 11 additions and 10 deletions.
  1. +11 −10 src/main/clojure/clojure/data/json.clj
View
21 src/main/clojure/clojure/data/json.clj
@@ -56,16 +56,17 @@
(defn- parse-array [^PushbackReader stream]
;; Expects to be called with the head of the stream AFTER the
;; opening bracket.
- (loop [c (.read stream), result (transient [])]
- (when (neg? c)
- (throw (EOFException. "JSON error (end-of-file inside array)")))
- (codepoint-case c
- :whitespace (recur (.read stream) result)
- \, (recur (.read stream) result)
- \] (persistent! result)
- (do (.unread stream c)
- (let [element (-parse stream true nil)]
- (recur (.read stream) (conj! result element)))))))
+ (loop [result (transient [])]
+ (let [c (.read stream)]
+ (when (neg? c)
+ (throw (EOFException. "JSON error (end-of-file inside array)")))
+ (codepoint-case c
+ :whitespace (recur result)
+ \, (recur result)
+ \] (persistent! result)
+ (do (.unread stream c)
+ (let [element (-parse stream true nil)]
+ (recur (conj! result element))))))))
(defn- parse-object [^PushbackReader stream]
;; Expects to be called with the head of the stream AFTER the

0 comments on commit 7b06144

Please sign in to comment.