Bug 173192 - URL::host should return a StringView
Summary: URL::host should return a StringView
Status: RESOLVED DUPLICATE of bug 185986
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-09 16:19 PDT by Alex Christensen
Modified: 2018-08-01 13:14 PDT (History)
5 users (show)

See Also:


Attachments
Patch (47.67 KB, patch)
2017-06-09 16:21 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (49.76 KB, patch)
2017-06-09 16:49 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (49.75 KB, patch)
2017-06-09 17:05 PDT, Alex Christensen
achristensen: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2017-06-09 16:19:40 PDT
URL::host should return a StringView
Comment 1 Alex Christensen 2017-06-09 16:21:34 PDT
Created attachment 312507 [details]
Patch
Comment 2 Alex Christensen 2017-06-09 16:49:52 PDT
Created attachment 312511 [details]
Patch
Comment 3 Chris Dumez 2017-06-09 16:53:15 PDT
Comment on attachment 312511 [details]
Patch

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

> Source/WebCore/ChangeLog:3
> +        URL::host should return a StringView

This adds quite a bit of toString() at call sites, which is unfortunate. Couldn't we add a new method which returns a StringView for call sites that actually need a view rather than a string?
Comment 4 Alex Christensen 2017-06-09 16:54:50 PDT
We should work towards removing those .toString() calls by doing things like making functions in HashSet<String> that take StringViews as arguments, etc.  This is a step in the right direction.
Comment 5 Chris Dumez 2017-06-09 16:57:01 PDT
(In reply to Alex Christensen from comment #4)
> We should work towards removing those .toString() calls by doing things like
> making functions in HashSet<String> that take StringViews as arguments, etc.
> This is a step in the right direction.

I also worry about the safety of this. People should be very careful when using StringViews.

e.g.
auto host = url.host();
// modify url
// host is now potentially bad.
Comment 6 Alex Christensen 2017-06-09 17:00:40 PDT
That's true for all StringViews.  That shouldn't prevent this patch.
If anything we should get rid of StringView.toStringWithoutCopying, but that's completely unrelated to this patch.
Comment 7 Alex Christensen 2017-06-09 17:05:49 PDT
Created attachment 312513 [details]
Patch
Comment 8 Build Bot 2017-06-09 17:08:59 PDT
Attachment 312513 [details] did not pass style-queue:


ERROR: Source/WebCore/page/SecurityOrigin.cpp:148:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
Total errors found: 1 in 48 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 Alex Christensen 2018-08-01 13:14:11 PDT

*** This bug has been marked as a duplicate of bug 185986 ***