| Summary: | String's find() / reverseFind() / replace() should take in a StringView instead of a String | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Chris Dumez <cdumez> | ||||||||||||||||||||||
| Component: | Web Template Framework | Assignee: | Chris Dumez <cdumez> | ||||||||||||||||||||||
| Status: | RESOLVED FIXED | ||||||||||||||||||||||||
| Severity: | Normal | CC: | alecflett, beidson, benjamin, changseok, cmarcelo, darin, dino, eric.carlson, esprehn+autocc, ews-watchlist, galpeter, ggaren, glenn, gyuyoung.kim, hi, hta, jer.noble, joepeck, jsbell, keith_miller, kondapallykalyan, luiz, mark.lam, mifenton, msaboff, pangle, philipj, saam, sergio, tommyw, tzagallo, webkit-bug-importer | ||||||||||||||||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||||||||||||||||
| Version: | WebKit Nightly Build | ||||||||||||||||||||||||
| Hardware: | Unspecified | ||||||||||||||||||||||||
| OS: | Unspecified | ||||||||||||||||||||||||
| See Also: |
https://bugs.webkit.org/show_bug.cgi?id=238235 https://bugs.webkit.org/show_bug.cgi?id=238264 https://bugs.webkit.org/show_bug.cgi?id=238333 |
||||||||||||||||||||||||
| Attachments: |
|
||||||||||||||||||||||||
|
Description
Chris Dumez
2022-03-23 13:54:17 PDT
Created attachment 455549 [details]
Patch
Created attachment 455552 [details]
Patch
Created attachment 455573 [details]
Patch
Created attachment 455598 [details]
Patch
Created attachment 455601 [details]
Patch
Created attachment 455604 [details]
Patch
Created attachment 455607 [details]
Patch
Created attachment 455610 [details]
Patch
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. (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(); } ``` Created attachment 455641 [details]
Patch
Created attachment 455642 [details]
Patch
Comment on attachment 455642 [details] Patch Clearing flags on attachment: 455642 Committed r291800 (248828@trunk): <https://commits.webkit.org/248828@trunk> All reviewed patches have been landed. Closing bug. |