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}
This commit is contained in:
parent
5990cd6aff
commit
26f617f1bc
1
AUTHORS
1
AUTHORS
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user