Uses WTF::String::Number instead of WTF::String::format in CSSPrimitiveValue::CustomCSSText. #15830
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CSSPrimitiveValue::CustomCSSText can be called huge amount of times
through InspectorDOMSnapshotAgent::getSnapshot. It underlyingly calls
WTF::String::format which is sort of expensive by considering the huge
call volume.
Actually CustomCSSText only needs to convert number to string. And
WTF::String provides a cheaper way, String::Number, to achieve same
goal.
WTF::String uses WTF Dtoa function to mimic "%.[precision]g" format. According to C11 standard
(http://port70.net/~nsz/c/c11/n1570.html#7.21.6), when using "%[.percisiong]g" format,
(1) The exponent always contains at least two digits, and only as many more digits as
necessary to represent the exponent. If the value is zero, the exponent is zero.
(2) Finally, unless the # flag is used, any trailing zeros are removed from the
fractional portion of the result and the decimal-point character is removed if there
is no fractional portion remaining.
But the WTF Dota function doesn't comply with the rules. Fix it in this change.
Change-Id: I896981f54aa0e327c85d6bc4cb87dd9a0291e124
Reviewed-on: https://chromium-review.googlesource.com/1512138
WPT-Export-Revision: ad2ac74a96a48d2f22205190b48a0f66775ad7d9