Bug 59151 - Provide default constructors for HashMap iterators
Summary: Provide default constructors for HashMap iterators
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-21 16:07 PDT by Vitaly Repeshko
Modified: 2011-04-22 15:01 PDT (History)
3 users (show)

See Also:


Attachments
patch (1.61 KB, patch)
2011-04-21 16:14 PDT, Vitaly Repeshko
abarth: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vitaly Repeshko 2011-04-21 16:07:27 PDT
[WTF] Provide default constructors for HashMap iterators
Comment 1 Vitaly Repeshko 2011-04-21 16:14:44 PDT
Created attachment 90625 [details]
patch
Comment 2 Adam Barth 2011-04-21 16:30:05 PDT
Comment on attachment 90625 [details]
patch

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

> Source/JavaScriptCore/wtf/HashTable.h:1123
> +        HashTableConstIteratorAdapter() {}

Do we need to initialize m_impl to anything (like null) or does it do that itself?
Comment 3 Adam Barth 2011-04-21 16:30:18 PDT
+mjs for WTF foo.
Comment 4 Vitaly Repeshko 2011-04-21 16:32:12 PDT
(In reply to comment #2)
> (From update of attachment 90625 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=90625&action=review
> 
> > Source/JavaScriptCore/wtf/HashTable.h:1123
> > +        HashTableConstIteratorAdapter() {}
> 
> Do we need to initialize m_impl to anything (like null) or does it do that itself?

Unlike the adapter it has a default constructor. So I don't think it should be initialized.
Comment 5 Sam Weinig 2011-04-21 19:56:48 PDT
Why are these needed? What will they be used for?
Comment 6 Vitaly Repeshko 2011-04-21 20:16:46 PDT
(In reply to comment #5)
> Why are these needed? What will they be used for?

Right now you can't declare a variable or class field of type HashMap::iterator without immediately initializing it. This is inconsistent with wtf::Vector and STL iterators.

My specific intended usage for them is to implement a lightweight iterator over EventTarget's listeners. EventTarget has a map of vectors. So the listener iterator simply combines a map iterator and an index. The problem is that the listener map is optional and the map iterator can't be initialized when it's NULL without using some dummy map.
Comment 7 Adam Barth 2011-04-21 22:11:37 PDT
I asked Vitaly to post this as a separate patch because the folks who would review this patch might not be the same folks who would be interested in reviewing the rest of his change.
Comment 8 Adam Barth 2011-04-22 09:02:41 PDT
Comment on attachment 90625 [details]
patch

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

> Source/JavaScriptCore/ChangeLog:7
> +

I would add some more explanation here about why you're making this change (i.e., that you plan to use it in another patch shortly).
Comment 9 Vitaly Repeshko 2011-04-22 15:01:40 PDT
	M	Source/JavaScriptCore/ChangeLog
	M	Source/JavaScriptCore/wtf/HashTable.h
Committed r84687