Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Issue 5567005: JSON stringify collects substrings in one builder array rather than using reg... (Closed)

Created:
10 years ago by sandholm
Modified:
9 years, 7 months ago
CC:
v8-dev, William Hesse
Visibility:
Public.

Description

JSON stringify collects substrings in one builder array rather than using regular string cons.

Patch Set 1 #

Total comments: 19

Patch Set 2 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+56 lines, -31 lines) Patch
M src/json.js View 1 1 chunk +56 lines, -31 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
sandholm
10 years ago (2010-12-05 12:56:22 UTC) #1
Erik Corry
STV! http://codereview.chromium.org/5567005/diff/1/src/json.js File src/json.js (right): http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode213 src/json.js:213: if (builder.pop() != ",") { This seems a ...
10 years ago (2010-12-05 15:09:06 UTC) #2
Lasse Reichstein
LVGTM too. Maybe worth applying to the non-basic Stringify too. http://codereview.chromium.org/5567005/diff/1/src/json.js File src/json.js (right): http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode210 ...
10 years ago (2010-12-06 08:48:45 UTC) #3
sandholm
10 years ago (2010-12-06 11:42:31 UTC) #4
http://codereview.chromium.org/5567005/diff/1/src/json.js
File src/json.js (right):

http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode213
src/json.js:213: if (builder.pop() != ",") {
I added a comment.
On 2010/12/05 15:09:06, Erik Corry wrote:
> This seems a bit indirect.  I think it would be clearer to just say if (len ==
> 0).  Is this version faster?

http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode229
src/json.js:229: builder.push(%QuoteJSONString(p), ":");
I experimented a bit. Will submit another change.
On 2010/12/05 15:09:06, Erik Corry wrote:
> If you didn't already try it I think it would be interesting to experiment
with
> having QuoteJSONString not add the quotes.  We should be faster at adding the
> quotes now and it would open up the possibility of just returning the string
> unchanged which should be the common case.  We can save that for another
change
> though.

http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode241
src/json.js:241: if (builder.pop() != ",") {
I added a comment
On 2010/12/05 15:09:06, Erik Corry wrote:
> Again, I find this convoluted.  A boolean variable that gets set if the for
loop
> is non-empty would be clearer.

http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode258
src/json.js:258: builder.push(($isFinite(value) ? $String(value) : "null"));
On 2010/12/06 08:48:45, Lasse Reichstein wrote:
> Use %_NumberToString instead of the generic $String. You know it's a number.
(Or
> use NonStringToString, but it will just test for being a number and call
> %_NumberToString)

Done.

http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode258
src/json.js:258: builder.push(($isFinite(value) ? $String(value) : "null"));
On 2010/12/05 15:09:06, Erik Corry wrote:
> I wonder how $String compares speedwise to ("" + value).

Done.

http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode264
src/json.js:264: value = $Number(value);
On 2010/12/06 08:48:45, Lasse Reichstein wrote:
> use %_ValueOf to extract the number.

Done.

http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode265
src/json.js:265: builder.push(($isFinite(value) ? $String(value) : "null"));
On 2010/12/06 08:48:45, Lasse Reichstein wrote:
> %_NumberToString here too.

Done.

http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode270
src/json.js:270: } else { // Regular non-wrapped object
On 2010/12/05 15:09:06, Erik Corry wrote:
> There should be 2 spaces before //

Done.

http://codereview.chromium.org/5567005/diff/1/src/json.js#newcode270
src/json.js:270: } else { // Regular non-wrapped object
On 2010/12/06 08:48:45, Lasse Reichstein wrote:
> I would put the comment on the next line instead.

Done.

Powered by Google App Engine
This is Rietveld 408576698