File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9797 #?@(:clj [utils/warn-on-reflection-var @utils/warn-on-reflection-var
9898 utils/unchecked-math-var @utils/unchecked-math-var])}
9999 (let [reader (r/indexing-push-back-reader (r/string-push-back-reader s))
100- eval-string+? (when opts (:sci.impl/eval-string+ opts))
101- parse-opts (parser/parse-opts ctx nil )]
100+ eval-string+? (when opts (:sci.impl/eval-string+ opts))]
102101 (loop [ret nil ]
103- (let [expr (parser/parse-next* reader parse-opts )]
102+ (let [expr (parser/parse-next ctx reader )]
104103 (if (utils/kw-identical? parser/eof expr)
105104 (if eval-string+?
106105 {:val ret
Original file line number Diff line number Diff line change 2020 :clj (instance? clojure.tools.reader.reader_types.IndexingReader reader)
2121 :cljs (implements? r/IndexingReader reader))
2222 reader
23- (r/indexing-push-back-reader reader))
24- parse-opts (parser/parse-opts ctx nil )]
23+ (r/indexing-push-back-reader reader))]
2524 (loop [ret nil ]
26- (let [x (parser/parse-next* reader parse-opts )]
25+ (let [x (parser/parse-next ctx reader )]
2726 (if (utils/kw-identical? parser/eof x)
2827 ret
2928 (recur (utils/eval ctx x)))))))
Original file line number Diff line number Diff line change 188188 :file @utils/current-file)
189189 e)))))
190190
191+ ; ; The last ctx and opts with their parse options, so callers that parse form
192+ ; ; by form with the same ctx and opts reuse them
193+ (def last-parse-opts (volatile! nil ))
194+
191195(defn parse-next
192196 ([ctx r]
193197 (parse-next ctx r nil ))
194198 ([ctx r opts]
195- (parse-next* r (parse-opts ctx opts))))
199+ (let [cached @last-parse-opts
200+ edamame-opts (if (and cached
201+ (identical? ctx (nth cached 0 ))
202+ (identical? opts (nth cached 1 )))
203+ (nth cached 2 )
204+ (let [edamame-opts (parse-opts ctx opts)]
205+ (vreset! last-parse-opts [ctx opts edamame-opts])
206+ edamame-opts))]
207+ (parse-next* r edamame-opts))))
196208
197209(defn reader [x]
198210 (edamame/reader x))
You can’t perform that action at this time.
0 commit comments