WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 238287
String's find() / reverseFind() / replace() should take in a StringView instead of a String
https://bugs.webkit.org/show_bug.cgi?id=238287
Summary
String's find() / reverseFind() / replace() should take in a StringView inste...
Chris Dumez
Reported
2022-03-23 13:54:17 PDT
String's find() / reverseFind() / replace() should take in a StringView instead of a String, to avoid unnecessary String construction.
Attachments
Patch
(35.26 KB, patch)
2022-03-23 13:58 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(37.24 KB, patch)
2022-03-23 14:17 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(38.36 KB, patch)
2022-03-23 15:58 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(56.93 KB, patch)
2022-03-23 19:27 PDT
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(57.84 KB, patch)
2022-03-23 21:09 PDT
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(57.84 KB, patch)
2022-03-23 21:47 PDT
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(56.85 KB, patch)
2022-03-23 22:15 PDT
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(56.85 KB, patch)
2022-03-23 23:03 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(72.23 KB, patch)
2022-03-24 08:28 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(72.25 KB, patch)
2022-03-24 08:36 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(9)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2022-03-23 13:58:48 PDT
Created
attachment 455549
[details]
Patch
Chris Dumez
Comment 2
2022-03-23 14:17:30 PDT
Created
attachment 455552
[details]
Patch
Chris Dumez
Comment 3
2022-03-23 15:58:55 PDT
Created
attachment 455573
[details]
Patch
Chris Dumez
Comment 4
2022-03-23 19:27:12 PDT
Created
attachment 455598
[details]
Patch
Chris Dumez
Comment 5
2022-03-23 21:09:39 PDT
Created
attachment 455601
[details]
Patch
Chris Dumez
Comment 6
2022-03-23 21:47:01 PDT
Created
attachment 455604
[details]
Patch
Chris Dumez
Comment 7
2022-03-23 22:15:39 PDT
Created
attachment 455607
[details]
Patch
Chris Dumez
Comment 8
2022-03-23 23:03:40 PDT
Created
attachment 455610
[details]
Patch
Darin Adler
Comment 9
2022-03-24 08:13:37 PDT
Comment on
attachment 455610
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=455610&action=review
> Source/WTF/wtf/text/AtomString.h:124 > + size_t findIgnoringASCIICase(StringView, unsigned startOffset) const;
Strange that we call it "start" in find and call it "startOffset" in findIgnoringASCIICase. Also strange that one uses a defaulted argument and the other uses overloading.
> Source/WTF/wtf/text/StringImpl.cpp:964 > if (UNLIKELY(!matchString))
I typically like to write isNull() rather than depending on operator!, but I suppose both work?
> Source/WTF/wtf/text/StringImpl.h:436 > + WTF_EXPORT_PRIVATE size_t find(StringView, unsigned index);
I find the mix of "index", "start", and "startOffset" slightly annoying.
> Source/WebCore/page/UserContentURLPattern.cpp:66 > static NeverDestroyed<const String> schemeSeparator(MAKE_STATIC_STRING_IMPL("://"));
This is now never used as a String, so I suggest we just make it an ASCIILiteral or a const char* or an auto. No need for NeverDestroyed any more.
> Source/WebCore/platform/network/curl/CurlMultipartHandle.cpp:55 > + auto splitPosistion = header.find(':');
Noticed the "posistion" typo here.
> Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp:58 > + size_t cLocalePosition = languages.find("c"_s);
Even this can be changed so it doesn’t involve creating/destroying strings. No reason Vector::find can’t be changed to work with anything that can do == with the Vector elements, doesn’t need to actually be the same type as the element. Not that you should do this right now.
Chris Dumez
Comment 10
2022-03-24 08:21:10 PDT
(In reply to Darin Adler from
comment #9
)
> Comment on
attachment 455610
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=455610&action=review
> > > Source/WTF/wtf/text/AtomString.h:124 > > + size_t findIgnoringASCIICase(StringView, unsigned startOffset) const; > > Strange that we call it "start" in find and call it "startOffset" in > findIgnoringASCIICase. Also strange that one uses a defaulted argument and > the other uses overloading. > > > Source/WTF/wtf/text/StringImpl.cpp:964 > > if (UNLIKELY(!matchString)) > > I typically like to write isNull() rather than depending on operator!, but I > suppose both work?
Yes, it is identical: ``` inline StringView::operator bool() const { return !isNull(); } ```
Chris Dumez
Comment 11
2022-03-24 08:28:33 PDT
Created
attachment 455641
[details]
Patch
Chris Dumez
Comment 12
2022-03-24 08:36:03 PDT
Created
attachment 455642
[details]
Patch
Chris Dumez
Comment 13
2022-03-24 09:55:54 PDT
Comment on
attachment 455642
[details]
Patch Clearing flags on attachment: 455642 Committed
r291800
(
248828@trunk
): <
https://commits.webkit.org/248828@trunk
>
Chris Dumez
Comment 14
2022-03-24 09:55:59 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 15
2022-03-24 09:56:18 PDT
<
rdar://problem/90774749
>
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