Bug 179907 - Reduce WTF::String operations that do unnecessary Unicode operations instead of ASCII
Summary: Reduce WTF::String operations that do unnecessary Unicode operations instead ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Darin Adler
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-20 19:40 PST by Darin Adler
Modified: 2017-11-23 16:35 PST (History)
5 users (show)

See Also:


Attachments
Patch (399.19 KB, patch)
2017-11-20 22:04 PST, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (409.84 KB, patch)
2017-11-20 22:38 PST, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (411.50 KB, patch)
2017-11-20 22:53 PST, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (415.11 KB, patch)
2017-11-21 04:47 PST, Darin Adler
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews126 for ios-simulator-wk2 (901.16 KB, application/zip)
2017-11-21 06:07 PST, EWS Watchlist
no flags Details
Patch (421.56 KB, patch)
2017-11-21 06:40 PST, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (426.56 KB, patch)
2017-11-21 08:36 PST, Darin Adler
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2017-11-20 19:40:00 PST
Reduce WTF::String operations that do unnecessary Unicode operations instead of ASCII
Comment 1 Darin Adler 2017-11-20 22:04:00 PST Comment hidden (obsolete)
Comment 2 EWS Watchlist 2017-11-20 22:07:35 PST Comment hidden (obsolete)
Comment 3 Darin Adler 2017-11-20 22:38:49 PST Comment hidden (obsolete)
Comment 4 EWS Watchlist 2017-11-20 22:40:54 PST Comment hidden (obsolete)
Comment 5 Darin Adler 2017-11-20 22:53:39 PST Comment hidden (obsolete)
Comment 6 EWS Watchlist 2017-11-20 22:57:00 PST Comment hidden (obsolete)
Comment 7 Darin Adler 2017-11-21 04:47:57 PST Comment hidden (obsolete)
Comment 8 EWS Watchlist 2017-11-21 04:50:37 PST Comment hidden (obsolete)
Comment 9 EWS Watchlist 2017-11-21 06:07:13 PST Comment hidden (obsolete)
Comment 10 EWS Watchlist 2017-11-21 06:07:14 PST Comment hidden (obsolete)
Comment 11 Darin Adler 2017-11-21 06:40:11 PST Comment hidden (obsolete)
Comment 12 EWS Watchlist 2017-11-21 06:43:42 PST Comment hidden (obsolete)
Comment 13 Darin Adler 2017-11-21 08:36:21 PST
Created attachment 327412 [details]
Patch
Comment 14 EWS Watchlist 2017-11-21 08:39:50 PST
Attachment 327412 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/text/StringImpl.h:1060:  Please replace ASSERT_WITH_SECURITY_IMPLICATION() with RELEASE_ASSERT_WITH_SECURITY_IMPLICATION().  [security/assertion] [5]
ERROR: Source/WTF/wtf/text/WTFString.h:427:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Source/WTF/wtf/text/WTFString.h:432:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
Total errors found: 3 in 136 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 15 Darin Adler 2017-11-21 12:45:10 PST
Comment on attachment 327412 [details]
Patch

OK, working well, compiling and passing tests everywhere, and ready for review now.
Comment 16 Darin Adler 2017-11-22 10:10:06 PST
No pressure, Sam, but I did notice you reviewing another patch.
Comment 17 Sam Weinig 2017-11-22 17:40:04 PST
Comment on attachment 327412 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=327412&action=review

> Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp:84
> +    ASSERT(result->refCount());

Does this still do the right thing for immortal strings?

> Source/WebCore/page/SecurityOrigin.cpp:333
>  static bool isFeedWithNestedProtocolInHTTPFamily(const URL& url)
>  {

I wonder if we still need this function, given we don't really display feed: urls anymore.

> Source/WebCore/platform/network/curl/ResourceResponseCurl.cpp:95
> +        auto key = header.left(splitPosition).stripWhiteSpace();

Can this be done as a single additional allocation by doing something like (the admittedly much longer):

auto key = StringView { header }.left(splitPosition).stripLeadingAndTrailingMatchedCharacters(SpaceOrNewlinePredicate { }).toString();

> Source/WebCore/platform/network/curl/ResourceResponseCurl.cpp:112
> -    auto httpVersionEndPosition = statusLine.find(" ");
> +    auto httpVersionEndPosition = statusLine.find(' ');

I wonder if we can make this a compile error, by statically asserting that a literal string is longer than one character long.
Comment 18 Darin Adler 2017-11-23 09:09:32 PST
Comment on attachment 327412 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=327412&action=review

>> Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp:84
>> +    ASSERT(result->refCount());
> 
> Does this still do the right thing for immortal strings?

Well, kind of; it will return false for an immortal string if absolutely no one is holding a reference to it. I guess I can roll this back because it was more correct the old way. But it annoys me to have a function that is literally used only in these two places in this one file and only for an assertion.

>> Source/WebCore/page/SecurityOrigin.cpp:333
>>  {
> 
> I wonder if we still need this function, given we don't really display feed: urls anymore.

Good point; would be great to figure that out and remove this. You brought this into the world, maybe you should take it out?

>> Source/WebCore/platform/network/curl/ResourceResponseCurl.cpp:95
>> +        auto key = header.left(splitPosition).stripWhiteSpace();
> 
> Can this be done as a single additional allocation by doing something like (the admittedly much longer):
> 
> auto key = StringView { header }.left(splitPosition).stripLeadingAndTrailingMatchedCharacters(SpaceOrNewlinePredicate { }).toString();

Yes, and also it should be dealing with HTTP’s definition of whitespace, not the general purpose whitespace definition from Unicode. I decided to leave this alone for now since it’s in the curl-specific code.

>> Source/WebCore/platform/network/curl/ResourceResponseCurl.cpp:112
>> +    auto httpVersionEndPosition = statusLine.find(' ');
> 
> I wonder if we can make this a compile error, by statically asserting that a literal string is longer than one character long.

I bet we can.
Comment 19 Darin Adler 2017-11-23 09:32:49 PST
Committed r225117: <https://trac.webkit.org/changeset/225117>
Comment 20 Radar WebKit Bug Importer 2017-11-23 09:34:20 PST
<rdar://problem/35677306>
Comment 21 Carlos Alberto Lopez Perez 2017-11-23 16:35:40 PST
Committed r225124: <https://trac.webkit.org/changeset/225124>