Optimise IntToString by avoiding string allocation.
Use a fixed-sized temporary buffer on the stack for IntToString and
variants, rather than allocating a string.
This reduces the time to run IntToString in a microbenchmark by 70%, and
the code size by 30%, both on Android arm7. See the bug for more details.
Since all the *Int*ToString* functions share a common implementation,
they all benefit from this change.
Security implications: If this function overflowed its buffer, then this
change would change a heap overflow bug to a stack overflow
bug. However, the unit tests in combination with the DCHECKs in the code
provide a strong guarantee that this function does not overflow its
buffer. The compiler also adds stack-smashing protection.
BUG=535972
TEST=base_unittests
Review URL: https://codereview.chromium.org/1359253003
Cr-Commit-Position: refs/heads/master@{#350883}
1 file changed