Bug 144676

Summary: Don't allocate a StringImpl for every Number JSValue in JSON.stringify().
Product: WebKit Reporter: Andreas Kling <kling>
Component: JavaScriptCoreAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, commit-queue, ggaren, kling, msaboff
Priority: P2 Keywords: Performance
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch darin: review+

Description Andreas Kling 2015-05-06 00:53:46 PDT
We can do a lot better on Kraken/json-stringify-tinderbox!

For example:
json-stringify-tinderbox        63.370+-3.319      ^      56.031+-3.150         ^ definitely 1.1310x faster
Comment 1 Andreas Kling 2015-05-06 00:54:46 PDT
Created attachment 252461 [details]
Patch
Comment 2 WebKit Commit Bot 2015-05-06 00:56:32 PDT
Attachment 252461 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/runtime/JSONObject.cpp:41:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Andreas Kling 2015-05-06 01:39:05 PDT
Created attachment 252462 [details]
Patch
Comment 4 Darin Adler 2015-05-06 09:23:09 PDT
Comment on attachment 252462 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=252462&action=review

> Source/JavaScriptCore/runtime/JSONObject.cpp:399
> +            NumberToStringBuffer buffer;
> +            builder.append(numberToString(number, buffer));

StringBuilder has a function named appendECMAScriptNumber. I suggest you use that instead, which would make your patch even smaller.
Comment 5 Andreas Kling 2015-05-06 10:12:05 PDT
Committed r183874: <http://trac.webkit.org/changeset/183874>