WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
239289
Drop inefficient String::append() overloads
https://bugs.webkit.org/show_bug.cgi?id=239289
Summary
Drop inefficient String::append() overloads
Chris Dumez
Reported
2022-04-13 10:34:40 PDT
Drop inefficient String::append() overloads to push developers to use StringBuilder / makeString() instead.
Attachments
Patch
(131.91 KB, patch)
2022-04-13 10:40 PDT
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(135.72 KB, patch)
2022-04-13 11:04 PDT
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(137.13 KB, patch)
2022-04-13 12:03 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(52.08 KB, patch)
2022-04-14 07:39 PDT
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(52.66 KB, patch)
2022-04-14 07:51 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2022-04-13 10:40:09 PDT
Created
attachment 457545
[details]
Patch
Chris Dumez
Comment 2
2022-04-13 11:04:41 PDT
Created
attachment 457547
[details]
Patch
Chris Dumez
Comment 3
2022-04-13 12:03:36 PDT
Created
attachment 457553
[details]
Patch
Sam Weinig
Comment 4
2022-04-13 14:53:38 PDT
Comment on
attachment 457553
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=457553&action=review
> Source/WebCore/Modules/indexeddb/IDBKeyData.cpp:375 > + result = makeString(StringView(result).left(147), "..."_s);
This hurts me but its just a logging string so I will not be overly upset.
> Source/WebCore/Modules/indexeddb/shared/IDBIndexInfo.cpp:65 > + return makeString(indentString.toString(), "Index: ", m_name, " (", m_identifier, ") keyPath: ", WebCore::loggingString(m_keyPath), '\n');
This should probably be: indentString.append("Index: ", m_name, " (", m_identifier, ") keyPath: ", WebCore::loggingString(m_keyPath), '\n'); return indentString.toString(); or just makeString(WTF::Indentation<1> { indent }, "Index: ", m_name, " (", m_identifier, ") keyPath: ", WebCore::loggingString(m_keyPath), '\n');
> Source/WebCore/inspector/agents/InspectorDOMAgent.cpp:1776 > + nodeValue = makeString(StringView(nodeValue).left(maxTextSize), ellipsisUChar);
We should probably be using ellipsisUChar everywhere we use "..." if we want to be good macOS citizens (don't ned to make that change now though).
Darin Adler
Comment 5
2022-04-13 14:59:40 PDT
Comment on
attachment 457553
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=457553&action=review
Seems like the substring(0, ...) changes to left() are not closely related to removing String::append overloads. Just a separate change included in the same patch but not mention in the title. And many of those are cases where left often allocates a new String. Some of them could be using StringView instead.
> Source/JavaScriptCore/runtime/IntlObject.cpp:961 > + foundLocale = makeString(foundLocaleView.left(matcherResult.extensionIndex), supportedExtension.toString(), foundLocaleView.substring(matcherResult.extensionIndex));
Not clear how cheap StringBuilder::toString is. If it’s at all expensive, we could make makeString support StringBuilder directly without doing any memory allocation, although obviously that work need not be done in this patch.
> Source/WTF/wtf/text/StringBuilder.h:64 > + void append(ASCIILiteral);
We need to move the model to where the set of things supported by StringBuilder are the same as the set supported by makeString without so much repeated code.
> Source/WebCore/Modules/indexeddb/IDBCursor.cpp:329 > + LOG(IndexedDB, "IDBCursor::setGetResult - current key %s", getResult.keyData().loggingString().left(100).utf8().data());
Here’s one example I noticed before realizing the patter than the substring/left changes were following: Can this be done with StringView instead? Why allocate the truncated string just to use it to call utf8()?
Chris Dumez
Comment 6
2022-04-13 16:08:11 PDT
(In reply to Darin Adler from
comment #5
)
> Comment on
attachment 457553
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=457553&action=review
> > Seems like the substring(0, ...) changes to left() are not closely related > to removing String::append overloads. Just a separate change included in the > same patch but not mention in the title.
Yes, I got a little too excited I think :) Splitting this part out into
Bug 239306
and adopting more StringView in the process.
Darin Adler
Comment 7
2022-04-13 16:09:17 PDT
(In reply to Chris Dumez from
comment #6
)
> Yes, I got a little too excited I think :)
Oh, I understand, believe me!
Chris Dumez
Comment 8
2022-04-14 07:39:08 PDT
Created
attachment 457625
[details]
Patch
Chris Dumez
Comment 9
2022-04-14 07:51:20 PDT
Created
attachment 457626
[details]
Patch
EWS
Comment 10
2022-04-14 10:56:29 PDT
Committed
r292879
(
249649@main
): <
https://commits.webkit.org/249649@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 457626
[details]
.
Radar WebKit Bug Importer
Comment 11
2022-04-14 10:57:16 PDT
<
rdar://problem/91764586
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug