Bug 38566 - [WTFURL] Add a class to represent the segments of a URL
Summary: [WTFURL] Add a class to represent the segments of a URL
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-05 00:07 PDT by Adam Barth
Modified: 2010-05-06 02:31 PDT (History)
3 users (show)

See Also:


Attachments
Patch (11.54 KB, patch)
2010-05-05 00:10 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
Patch (9.98 KB, patch)
2010-05-05 16:36 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
patch w/ update license block (10.09 KB, patch)
2010-05-05 18:31 PDT, Adam Barth
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2010-05-05 00:07:27 PDT
[WTFURL] Add a class to represent the segments of a URL
Comment 1 Adam Barth 2010-05-05 00:10:25 PDT
Created attachment 55090 [details]
Patch
Comment 2 Maciej Stachowiak 2010-05-05 15:39:19 PDT
Comment on attachment 55090 [details]
Patch


JavaScriptCore/wtf/url/src/URLSegments.h:88
 +      //        *Ref: 20                   20
Perhaps "Ref" should be called "Fragment" to match the RFC naming.

JavaScriptCore/wtf/url/src/URLSegments.h:108
 +      // Host name.
This comment doesn't seem to add any value.

JavaScriptCore/wtf/url/src/URLSegments.h:111
 +      // Port number.
This comment doesn't seem to add any value.

The other com,ments do convey some information, but they seem needlessly verbose. It seems like there is a common pattern of excluding delimiters from the range, and having -1 length if the delimiter character for that component is missing. Perhaps we could just say this once, instead of separately for every component.

JavaScriptCore/wtf/url/src/URLSegments.h:53
 +      // The default constructor is sufficient for the components.
This comment doesn't add any value.

JavaScriptCore/wtf/url/src/URLSegments.h:41
 +      // Identifies different components.
This comment doesn't add any value.

JavaScriptCore/wtf/url/src/URLSegments.h:130
 +      URLComponent ref;
ref should be fragment (again)

Please address
JavaScriptCore/wtf/url/src/URLSegments.cpp:58
 +          current = scheme.end() + 1; // Advance over the ':' at the end of the scheme.
If this code expects to be advancing past a specific character, perhaps an ASSERT would be a better way to document that than a comment.

JavaScriptCore/wtf/url/src/URLSegments.cpp:63
 +          current = username.end() + 1; // Advance over the '@' or ':' at the end.
If this code expects to be advancing past a specific character, perhaps an ASSERT would be a better way to document that than a comment.


JavaScriptCore/wtf/url/src/URLSegments.cpp:69
 +          current = password.end() + 1; // Advance over the '@' at the end.
If this code expects to be advancing past a specific character, perhaps an ASSERT would be a better way to document that than a comment.


JavaScriptCore/wtf/url/src/URLSegments.cpp:80
 +              return port.begin() - 1; // Back over delimiter.
If this code expects to be advancing past a specific character, perhaps an ASSERT would be a better way to document that than a comment.


JavaScriptCore/wtf/url/src/URLSegments.cpp:94
 +              return query.begin() - 1; // Back over delimiter.
If this code expects to be advancing past a specific character, perhaps an ASSERT would be a better way to document that than a comment.


JavaScriptCore/wtf/url/src/URLSegments.cpp:102
 +              return ref.begin(); // Back over delimiter.
If this code expects to be advancing past a specific character, perhaps an ASSERT would be a better way to document that than a comment.


JavaScriptCore/wtf/url/src/URLSegments.cpp:54
 +      // There will be some characters after the scheme like "://" and we don't
I don't see anything in this code that seems specific to advancing pass ://, it seems to just look at all the component ranges in turn.


r- for now to address the above issues. None of them are showstoppers, but it seems like there are enough different comments to warrant a new patch version.
Comment 3 Adam Barth 2010-05-05 16:32:35 PDT
> If this code expects to be advancing past a specific character, perhaps an
> ASSERT would be a better way to document that than a comment.

The string isn't available here (because it's stored separately from the segmentation), so we can't actually assert that here.

> r- for now to address the above issues. None of them are showstoppers, but it
> seems like there are enough different comments to warrant a new patch version.

I've addressed the remainder.  I'll be more agressive about making the comments more WebKit-like in future patches.
Comment 4 Adam Barth 2010-05-05 16:36:29 PDT
Created attachment 55172 [details]
Patch
Comment 5 Adam Barth 2010-05-05 18:31:40 PDT
Created attachment 55189 [details]
patch w/ update license block
Comment 6 Maciej Stachowiak 2010-05-06 01:03:07 PDT
Comment on attachment 55189 [details]
patch w/ update license block

r=me
Comment 7 Adam Barth 2010-05-06 01:10:29 PDT
Comment on attachment 55189 [details]
patch w/ update license block

Thanks!
Comment 8 WebKit Commit Bot 2010-05-06 02:31:17 PDT
Comment on attachment 55189 [details]
patch w/ update license block

Clearing flags on attachment: 55189

Committed r58874: <http://trac.webkit.org/changeset/58874>
Comment 9 WebKit Commit Bot 2010-05-06 02:31:23 PDT
All reviewed patches have been landed.  Closing bug.