Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Issue 1359253003: Optimise IntToString by avoiding string allocation. (Closed)

Created:
5 years, 2 months ago by Adam Rice
Modified:
5 years, 2 months ago
Reviewers:
Mark Mentovai
CC:
chromium-reviews, jshin+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

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 Committed: https://crrev.com/ad547d8741b466f19d50adbc0abb2b6a4b5524e8 Cr-Commit-Position: refs/heads/master@{#350883}

Patch Set 1 #

Total comments: 4

Patch Set 2 : Changes proposed by mark. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+13 lines, -11 lines) Patch
M base/strings/string_number_conversions.cc View 1 1 chunk +13 lines, -11 lines 0 comments Download

Messages

Total messages: 9 (2 generated)
Adam Rice
5 years, 2 months ago (2015-09-25 15:31:05 UTC) #2
Mark Mentovai
LGTM otherwise https://codereview.chromium.org/1359253003/diff/1/base/strings/string_number_conversions.cc File base/strings/string_number_conversions.cc (right): https://codereview.chromium.org/1359253003/diff/1/base/strings/string_number_conversions.cc#newcode35 base/strings/string_number_conversions.cc:35: typedef typename STR::value_type CHR; https://chromium-cpp.appspot.com/: use “using ...
5 years, 2 months ago (2015-09-25 15:35:28 UTC) #3
Adam Rice
https://codereview.chromium.org/1359253003/diff/1/base/strings/string_number_conversions.cc File base/strings/string_number_conversions.cc (right): https://codereview.chromium.org/1359253003/diff/1/base/strings/string_number_conversions.cc#newcode35 base/strings/string_number_conversions.cc:35: typedef typename STR::value_type CHR; On 2015/09/25 at 15:35:28, Mark ...
5 years, 2 months ago (2015-09-25 17:35:36 UTC) #4
Mark Mentovai
LGTM
5 years, 2 months ago (2015-09-25 17:37:09 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1359253003/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1359253003/20001
5 years, 2 months ago (2015-09-25 18:37:31 UTC) #7
commit-bot: I haz the power
Committed patchset #2 (id:20001)
5 years, 2 months ago (2015-09-25 19:27:58 UTC) #8
commit-bot: I haz the power
5 years, 2 months ago (2015-09-25 19:28:43 UTC) #9
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/ad547d8741b466f19d50adbc0abb2b6a4b5524e8
Cr-Commit-Position: refs/heads/master@{#350883}

Powered by Google App Engine
This is Rietveld 408576698