Commit 26f617f1 authored by demoneaux's avatar demoneaux Committed by Commit bot

Optimize JSON stringifying when `replacer` and `space` are falsey.

Most libraries use `JSON.stringify` with all three arguments [1] to allow for
configuration, even if `replacer` and `space` are falsey, causing the
optimized native stringifying to be missed. This commit allows for the common
case where `replacer` and `space` are not used to be fast.

[1]: https://github.com/hapijs/hapi/pull/3014

BUG=v8:4730
LOG=N

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/1710933002

Cr-Commit-Position: refs/heads/master@{#34174}
parent 5990cd6a
......@@ -42,6 +42,7 @@ Andrew Paprocki <andrew@ishiboo.com>
Andrei Kashcha <anvaka@gmail.com>
Bangfu Tao <bangfu.tao@samsung.com>
Ben Noordhuis <info@bnoordhuis.nl>
Benjamin Tan <demoneaux@gmail.com>
Bert Belder <bertbelder@gmail.com>
Burcu Dogan <burcujdogan@gmail.com>
Caitlin Potter <caitpotter88@gmail.com>
......
......@@ -234,6 +234,9 @@ function JSONStringify(value, replacer, space) {
} else {
gap = "";
}
if (!IS_CALLABLE(replacer) && !property_list && !gap && !IS_PROXY(value)) {
return %BasicJSONStringify(value);
}
return JSONSerialize('', {'': value}, replacer, new InternalArray(), "", gap);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment