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

Issue 2280723002: StringBuilder::append should not use reserveCapacity. (Closed)

Created:
4 years, 3 months ago by esprehn
Modified:
4 years, 3 months ago
Reviewers:
CC:
chromium-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@2785
Target Ref:
refs/pending/branch-heads/2785
Project:
chromium
Visibility:
Public.

Description

StringBuilder::append should not use reserveCapacity. reserveCapacity allocates the exact capacity specified which means when we had a 16bit buffer in StringBuilder and were appending 8bit strings to it we were constantly reallocating and copying the buffer. Instead we can just call Vector::append() directly since it has a template overload that can accept implicitly convertible types. I noticed this when looking at lever.co's web app loading in Instruments, it was spending 15% of the main thread time inside TextResource::decodedText which was 83% memmove, and 11% munmap. Switching to Vector::append should restore the correct size doubling behavior when appending LChars to a UChar StringBuilder and make this much faster. This was a regression from when I switched to using a Vector inside StringBuilder in: https://codereview.chromium.org/2046353002 Review-Url: https://codereview.chromium.org/2192293002 Cr-Commit-Position: refs/heads/master@{#408869} (cherry picked from commit 25fdbad21c66328e5ada9b9b436d3a8c146ca728) BUG=640598 TBR=govind@chromium.org Committed: https://chromium.googlesource.com/chromium/src/+/e3ca90f12717b30d69489e5bb446f72585d345be

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1 line, -3 lines) Patch
M third_party/WebKit/Source/wtf/text/StringBuilder.cpp View 1 chunk +1 line, -3 lines 0 comments Download

Messages

Total messages: 3 (2 generated)
esprehn
4 years, 3 months ago (2016-08-25 17:22:02 UTC) #3
Message was sent while issue was closed.
Committed patchset #1 (id:1) manually as
e3ca90f12717b30d69489e5bb446f72585d345be.

Powered by Google App Engine
This is Rietveld 408576698