Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Commit

Permalink
Optimize: Use new String to avoid unnecessary string object creation
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjmnt4n authored and Kit Cambridge committed Dec 24, 2014
1 parent 9932ca4 commit cefa14a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/json3.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
if (name == "bug-string-char-index") {
// IE <= 7 doesn't support accessing string characters using square
// bracket notation. IE 8 only supports this for primitives.
isSupported = "a"[0] != "a";
isSupported = ("a"[0] + Object("a")[0]) != "aa";
} else if (name == "json") {
// Indicates whether both `JSON.stringify` and `JSON.parse` are
// supported.
Expand Down Expand Up @@ -871,7 +871,7 @@
exports.parse = function (source, callback) {
var result, value;
Index = 0;
Source = "" + source;
Source = new String(source);
result = get(lex());
// If a JSON string contains multiple tokens, it is invalid.
if (lex() != "$") {
Expand Down

0 comments on commit cefa14a

Please sign in to comment.