Permalink
Browse files

remove runtime constructed char-escapes ObjMap

  • Loading branch information...
1 parent 4fbbfe6 commit 1cc6b7abda46e994f26829cb2a038165db180244 @swannodette swannodette committed Apr 27, 2013
Showing with 10 additions and 8 deletions.
  1. +10 −8 src/cljs/cljs/core.cljs
View
@@ -6439,19 +6439,21 @@ reduces them without incurring seq initialization"
[fmt & args]
(print (apply format fmt args)))
-(def ^:private char-escapes {"\"" "\\\""
- "\\" "\\\\"
- "\b" "\\b"
- "\f" "\\f"
- "\n" "\\n"
- "\r" "\\r"
- "\t" "\\t"})
+(def ^:private char-escapes
+ (js-obj
+ "\"" "\\\""
+ "\\" "\\\\"
+ "\b" "\\b"
+ "\f" "\\f"
+ "\n" "\\n"
+ "\r" "\\r"
+ "\t" "\\t"))
(defn ^:private quote-string
[s]
(str \"
(.replace s (js/RegExp "[\\\\\"\b\f\n\r\t]" "g")
- (fn [match] (get char-escapes match)))
+ (fn [match] (aget char-escapes match)))
\"))
(extend-protocol IPrintWithWriter

0 comments on commit 1cc6b7a

Please sign in to comment.