[webkit-reviews] review granted: [Bug 239500] Replace String::replaceWithLiteral() with a String::replace() overload that takes in an ASCIILiteral : [Attachment 457897] Patch
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Apr 19 10:44:55 PDT 2022
Darin Adler <darin at apple.com> has granted Chris Dumez <cdumez at apple.com>'s
request for review:
Bug 239500: Replace String::replaceWithLiteral() with a String::replace()
overload that takes in an ASCIILiteral
https://bugs.webkit.org/show_bug.cgi?id=239500
Attachment 457897: Patch
https://bugs.webkit.org/attachment.cgi?id=457897&action=review
--- Comment #2 from Darin Adler <darin at apple.com> ---
Comment on attachment 457897
--> https://bugs.webkit.org/attachment.cgi?id=457897
Patch
View in context: https://bugs.webkit.org/attachment.cgi?id=457897&action=review
> Source/WTF/wtf/text/WTFString.h:198
> + String& replace(UChar target, ASCIILiteral);
I would sort this up with the UChar/StringView overload above it.
> Source/WebCore/editing/markup.cpp:423
> + return result.toString().replace('\0', ""_s);
I wish it was clearer when to use ""_s and when to use emptyString(). I suppose
that ideally the two would always generate identical code, the more optimal of
the two.
Another possibility would be to add a function named something like removeAll.
Makes me realize that replace should maybe be named replaceAll.
> Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp:247
> + testString.replace('2', "3"_s);
If there were a lot of callers like this we’d probably want a replace(UChar,
UChar).
More information about the webkit-reviews
mailing list