Bug 171396 - Add WebCore::protocolIsJavaScript(StringView)
Summary: Add WebCore::protocolIsJavaScript(StringView)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords:
Depends on:
Blocks: 170925
  Show dependency treegraph
 
Reported: 2017-04-27 14:50 PDT by Daniel Bates
Modified: 2017-05-01 09:32 PDT (History)
3 users (show)

See Also:


Attachments
Patch (4.79 KB, patch)
2017-04-27 14:58 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2017-04-27 14:50:13 PDT
As suggested by Sam Weinig in bug 170925, comment 2, we should add an overload of WebCore::protocolIsJavaScript() that takes a StringView to avoid the need to perform a type conversion from StringView to String.
Comment 1 Daniel Bates 2017-04-27 14:58:11 PDT
Created attachment 308455 [details]
Patch
Comment 2 Alex Christensen 2017-04-28 14:28:41 PDT
Comment on attachment 308455 [details]
Patch

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

r=me
I think we should get rid of all instances of protocolIs that take Strings instead of URLs.  They're probably a marginal performance benefit, but we should really parse URLs rather than maintain a separate code path that looks enough like the URLParser.

> Source/WebCore/platform/URL.h:315
> +bool protocolIsJavaScript(StringView url);

Did you want to use this somewhere?  This patch only changes URL.h and URL.cpp.
Comment 3 Daniel Bates 2017-04-28 14:45:12 PDT
(In reply to Alex Christensen from comment #2)
> [...]
> I think we should get rid of all instances of protocolIs that take Strings
> instead of URLs.  They're probably a marginal performance benefit, but we
> should really parse URLs rather than maintain a separate code path that
> looks enough like the URLParser.
> 

We should investigate this. We should do this in the separate bug. 

> > Source/WebCore/platform/URL.h:315
> > +bool protocolIsJavaScript(StringView url);
> 
> Did you want to use this somewhere?  This patch only changes URL.h and
> URL.cpp.

As I mentioned in the ChangeLog entry, I plan to use this function in the patch for bug #170925.
Comment 4 Daniel Bates 2017-04-28 14:45:47 PDT
Comment on attachment 308455 [details]
Patch

Clearing flags on attachment: 308455

Committed r215949: <http://trac.webkit.org/changeset/215949>
Comment 5 Daniel Bates 2017-04-28 14:45:49 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Darin Adler 2017-05-01 09:32:46 PDT
(In reply to Alex Christensen from comment #2)
> I think we should get rid of all instances of protocolIs that take Strings
> instead of URLs. They're probably a marginal performance benefit, but we
> should really parse URLs rather than maintain a separate code path that
> looks enough like the URLParser.

I am not sure I agree.

If the performance benefit is tiny, then that’s OK.

Parsing an entire URL to do a properly-case-insensitive prefix check seems like massive overkill to me, so we should be sure a performance benefit is not there before dropping. I think there is at *least* an order of magnitude difference in the costs of the two operations.