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

Issue 2033293002: Implement StringImpl sharing for StringView::toString(). (Closed)

Created:
4 years, 6 months ago by esprehn
Modified:
4 years, 6 months ago
CC:
blink-reviews, blink-reviews-wtf_chromium.org, chromium-reviews, Mikhail
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Implement StringImpl sharing for StringView::toString(). Prior to https://codereview.chromium.org/2007103003 StringBuilder had an optimization that would share the StringImpl when calling append() with a String the first time. This meant that doing element.textContent on an Element with a single Text node child wouldn't need to string copy. The optimization also helps the parser, removing a string copy when flushing text in the HTML parser (flushPendingText) when there's a single text that was appended, and the text is a reasonable length (<= 65536 bytes). This optimization further helps any code that would potentially append an AtomicString to a StringBuilder and then do toAtomicString() or toString() by ensuring we return the same AtomicString again avoiding a bunch of work, and allowing the atomic string optimization to propagate to the result. This patch restores the StringBuilder optimization by adding a StringImpl* member to StringView and allowing toString() and toAtomicString() to return that member when the offset is zero and the length is the same as the input string. This patch also collapses the m_is8Bit flag into the m_impl by just reusing the field to know if the StringView is 8bit. We now store the shared empty 8bit or 16bit strings in the impl field for views created from sources that are not backed by StringImpl. Doing this keeps the StringView class to be only 2 ptrs and an unsigned wide. I also further simplified the code by using the union members directly and by adding a void* bytes() getter to StringImpl which removed the branch on is8Bit for the common case of constructing a StringView from a String or StringImpl with no offset, and the full length. BUG=615174 Committed: https://crrev.com/580cbf5d215fee758dd5c447cf03885b07bc9d2e Cr-Commit-Position: refs/heads/master@{#397986}

Patch Set 1 #

Patch Set 2 : add getptr. #

Patch Set 3 : Fix preload scanner bug. #

Total comments: 11
Unified diffs Side-by-side diffs Delta from patch set Stats (+143 lines, -74 lines) Patch
M third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp View 1 2 1 chunk +5 lines, -1 line 1 comment Download
M third_party/WebKit/Source/wtf/text/StringBuilder.h View 1 chunk +24 lines, -10 lines 2 comments Download
M third_party/WebKit/Source/wtf/text/StringBuilderTest.cpp View 2 chunks +32 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/StringImpl.h View 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/StringView.h View 1 8 chunks +58 lines, -46 lines 8 comments Download
M third_party/WebKit/Source/wtf/text/StringView.cpp View 3 chunks +11 lines, -13 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/StringViewTest.cpp View 1 chunk +12 lines, -4 lines 0 comments Download

Messages

Total messages: 28 (13 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2033293002/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2033293002/1
4 years, 6 months ago (2016-06-03 02:37:13 UTC) #2
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: ios-simulator on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/builds/15648)
4 years, 6 months ago (2016-06-03 02:51:42 UTC) #4
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2033293002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2033293002/20001
4 years, 6 months ago (2016-06-03 02:57:29 UTC) #6
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/240646)
4 years, 6 months ago (2016-06-03 04:19:34 UTC) #10
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2033293002/40001
4 years, 6 months ago (2016-06-03 20:26:31 UTC) #12
esprehn
https://codereview.chromium.org/2033293002/diff/40001/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp File third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp (right): https://codereview.chromium.org/2033293002/diff/40001/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp#newcode199 third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp:199: // ref to a string we're going to send ...
4 years, 6 months ago (2016-06-03 20:28:29 UTC) #13
esprehn
4 years, 6 months ago (2016-06-03 22:05:09 UTC) #16
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/233408)
4 years, 6 months ago (2016-06-04 02:35:49 UTC) #19
haraken
https://codereview.chromium.org/2033293002/diff/40001/third_party/WebKit/Source/wtf/text/StringBuilder.h File third_party/WebKit/Source/wtf/text/StringBuilder.h (right): https://codereview.chromium.org/2033293002/diff/40001/third_party/WebKit/Source/wtf/text/StringBuilder.h#newcode103 third_party/WebKit/Source/wtf/text/StringBuilder.h:103: m_string = impl; Don't we need to set m_buffer ...
4 years, 6 months ago (2016-06-06 02:28:52 UTC) #20
esprehn
https://codereview.chromium.org/2033293002/diff/40001/third_party/WebKit/Source/wtf/text/StringBuilder.h File third_party/WebKit/Source/wtf/text/StringBuilder.h (right): https://codereview.chromium.org/2033293002/diff/40001/third_party/WebKit/Source/wtf/text/StringBuilder.h#newcode103 third_party/WebKit/Source/wtf/text/StringBuilder.h:103: m_string = impl; On 2016/06/06 at 02:28:52, haraken wrote: ...
4 years, 6 months ago (2016-06-06 04:42:21 UTC) #21
haraken
LGTM https://codereview.chromium.org/2033293002/diff/40001/third_party/WebKit/Source/wtf/text/StringView.h File third_party/WebKit/Source/wtf/text/StringView.h (right): https://codereview.chromium.org/2033293002/diff/40001/third_party/WebKit/Source/wtf/text/StringView.h#newcode143 third_party/WebKit/Source/wtf/text/StringView.h:143: StringImpl* m_impl; On 2016/06/06 04:42:21, esprehn wrote: > ...
4 years, 6 months ago (2016-06-06 05:02:35 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2033293002/40001
4 years, 6 months ago (2016-06-06 05:05:06 UTC) #24
Yuta Kitamura
lgtm
4 years, 6 months ago (2016-06-06 05:36:36 UTC) #25
commit-bot: I haz the power
Committed patchset #3 (id:40001)
4 years, 6 months ago (2016-06-06 06:39:21 UTC) #26
commit-bot: I haz the power
4 years, 6 months ago (2016-06-06 06:40:33 UTC) #28
Message was sent while issue was closed.
Patchset 3 (id:??) landed as
https://crrev.com/580cbf5d215fee758dd5c447cf03885b07bc9d2e
Cr-Commit-Position: refs/heads/master@{#397986}

Powered by Google App Engine
This is Rietveld 408576698