Bug 126253

Summary: Move FilterIterator and IteratorPair to WTF and reimplement HashMap::keys() and HashMap::values() using IteratorPair
Product: WebKit Reporter: Sam Weinig <sam>
Component: New BugsAssignee: Sam Weinig <sam>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cmarcelo, commit-queue, gyuyoung.kim, rakuco
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch andersca: review+

Description Sam Weinig 2013-12-26 22:27:13 PST
Move FilterIterator and IteratorPair to WTF and replement HashMap::keys() and HashMap::values() using IteratorPair
Comment 1 Sam Weinig 2013-12-26 22:32:57 PST
Created attachment 220047 [details]
Patch
Comment 2 Sam Weinig 2013-12-26 22:35:22 PST
Anders mentioned he thought this might be a good idea, so I went ahead and did it. I like the cleanup of APIArray::elementsOfType(), but I am bummed I couldn't figure out how to remove the last bit of duplication (the typedef had been duplicated 4 times, and now is down to 2).
Comment 3 Sam Weinig 2013-12-28 13:17:20 PST
Committed r161114: <http://trac.webkit.org/changeset/161114>
Comment 4 Darin Adler 2013-12-29 22:39:54 PST
Comment on attachment 220047 [details]
Patch

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

> Source/WTF/wtf/IteratorPair.h:44
>      Iterator begin() { return m_begin; }
>      Iterator end() { return m_end; }
>  
> +    Iterator begin() const { return m_begin; }
> +    Iterator end() const { return m_end; }

Why do we need both? Why not just the const ones?
Comment 5 Sam Weinig 2013-12-30 11:02:47 PST
(In reply to comment #4)
> (From update of attachment 220047 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=220047&action=review
> 
> > Source/WTF/wtf/IteratorPair.h:44
> >      Iterator begin() { return m_begin; }
> >      Iterator end() { return m_end; }
> >  
> > +    Iterator begin() const { return m_begin; }
> > +    Iterator end() const { return m_end; }
> 
> Why do we need both? Why not just the const ones?

You're right, we don't need the non-const one.  I will remove it.
Comment 6 Sam Weinig 2013-12-30 20:17:52 PST
(In reply to comment #5)
> (In reply to comment #4)
> > (From update of attachment 220047 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=220047&action=review
> > 
> > > Source/WTF/wtf/IteratorPair.h:44
> > >      Iterator begin() { return m_begin; }
> > >      Iterator end() { return m_end; }
> > >  
> > > +    Iterator begin() const { return m_begin; }
> > > +    Iterator end() const { return m_end; }
> > 
> > Why do we need both? Why not just the const ones?
> 
> You're right, we don't need the non-const one.  I will remove it.

Fixed in http://trac.webkit.org/changeset/161162.