Bug 162518

Summary: Refactor URLParser
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch beidson: review+

Description Alex Christensen 2016-09-23 16:23:37 PDT
Refactor URLParser
Comment 1 Alex Christensen 2016-09-23 16:27:30 PDT
Created attachment 289717 [details]
Patch
Comment 2 Brady Eidson 2016-09-23 16:30:54 PDT
Comment on attachment 289717 [details]
Patch

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

> Source/WebCore/platform/URLParser.h:86
> +    using IPv4Address = uint32_t;

Is 'using' preferred over typedef?

> Source/WebCore/platform/URLParser.h:89
> +    using IPv6Address = std::array<uint16_t, 8>;

Why std::array instead of Vector?
Comment 3 Alex Christensen 2016-09-23 16:32:43 PDT
(In reply to comment #2)
> Comment on attachment 289717 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=289717&action=review
> 
> > Source/WebCore/platform/URLParser.h:86
> > +    using IPv4Address = uint32_t;
> 
> Is 'using' preferred over typedef?
Yes.  It works better with templates.
> 
> > Source/WebCore/platform/URLParser.h:89
> > +    using IPv6Address = std::array<uint16_t, 8>;
> 
> Why std::array instead of Vector?
We know it will have exactly 8 and only 8 elements.  No reason to keep track of size, and no reason to have capability of having more or less.  I would use an array, but that doesn't work as a template parameter.
Comment 4 Brady Eidson 2016-09-23 16:42:14 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > Comment on attachment 289717 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=289717&action=review
> > 
> > > Source/WebCore/platform/URLParser.h:86
> > > +    using IPv4Address = uint32_t;
> > 
> > Is 'using' preferred over typedef?
> Yes.  It works better with templates.
> > 
> > > Source/WebCore/platform/URLParser.h:89
> > > +    using IPv6Address = std::array<uint16_t, 8>;
> > 
> > Why std::array instead of Vector?
> We know it will have exactly 8 and only 8 elements. 

Vector with inline capacity accomplishes the same thing, no?
Comment 5 Alex Christensen 2016-09-23 16:43:18 PDT
http://trac.webkit.org/changeset/206337
Comment 6 Alex Christensen 2016-09-23 16:43:44 PDT
(In reply to comment #4)
> Vector with inline capacity accomplishes the same thing, no?
This has an unneeded unsigned value next to the values I care about.