Cut down on use of StringBuffer, possibly leading toward removing it entirely
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Mar 2019 00:27:10 +0000 (00:27 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Mar 2019 00:27:10 +0000 (00:27 +0000)
commit185929417ea249a880dd767ad463fbc439ef2081
tree4fcb59d98c6b394e83f3468cfc6c36a650eb95ac
parent6a74ff6cd97cbe30356f50128bc5ca62b09fe875
Cut down on use of StringBuffer, possibly leading toward removing it entirely
https://bugs.webkit.org/show_bug.cgi?id=195870

Reviewed by Daniel Bates.

Source/WebCore:

* dom/Document.cpp:
(WebCore::canonicalizedTitle): Fixed all the problems mentioned in "FIXME".
Made this a single function rather than a function template. Switch to
StringBuilder instead of StringBuffer. Return the original string if the
canonicalize operation doesn't change anything.
(WebCore::Document::updateTitle): Updated for the change above.

* platform/Length.cpp:
(WebCore::newCoordsArray): Use createUninitialized instead of StringBuffer.
Also got rid of unneeded use of upconvertedCharacters on a temporary string
that we explicitly created with 16-bit characters. The performance of this
function could be considerably simplified by not copying the original string
at all, but didn't do that at this time.

* platform/text/TextCodecUTF16.cpp:
(WebCore::TextCodecUTF16::decode): Use createUninitialized instead of
StringBuffer. Also renamed numChars to numCodeUnits to both switch to complete
words and to be slightly more accurate.

* rendering/RenderText.cpp:
(WebCore::convertNoBreakSpace): Added.
(WebCore::capitalize): Use Vector instead of StringBuffer. Simplify code by
using convertNoBreakSpace function. Removed code that was using StringImpl
directly for a tiny speed boost; if we want to optimize the performance of
this function we would need to do more than that. Return the original string
if it happens to already be capitalized.

Source/WTF:

* wtf/URL.cpp: Remove a now-inaccurate comment mentioning StringBuffer.

* wtf/text/StringView.cpp:
(WTF::convertASCIICase): Use createUninitialized instead of StringBuffer.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243118 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/URL.cpp
Source/WTF/wtf/text/StringView.cpp
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/platform/Length.cpp
Source/WebCore/platform/text/TextCodecUTF16.cpp
Source/WebCore/rendering/RenderText.cpp