Skip to content

Commit

Permalink
Remove last redundant calls to .read in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart Sierra committed Oct 5, 2012
1 parent 25d4d28 commit 7b06144
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/main/clojure/clojure/data/json.clj
Expand Up @@ -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
Expand Down

0 comments on commit 7b06144

Please sign in to comment.