Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: src/objects.h

Issue 329253004: Optimize Map/Set.prototype.forEach (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update count to fix merge issue Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/collection.js ('K') | « src/collection.js ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 9d96b503386c840222139aeee9cca23751cc4b2f..6e4424dc5f20637808e06583281c5fbc1db9310b 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -4490,11 +4490,11 @@ class OrderedHashMap:public OrderedHashTable<
Handle<Object> key,
Handle<Object> value);
- private:
Object* ValueAt(int entry) {
return get(EntryToIndex(entry) + kValueOffset);
}
+ private:
static const int kValueOffset = 1;
};
@@ -10179,8 +10179,21 @@ class OrderedHashTableIterator: public JSObject {
// end.
static Handle<JSObject> Next(Handle<Derived> iterator);
+ // Whether the iterator has more elements. This needs to be called before
+ // calling |CurrentKey| and/or |CurrentValue|.
+ bool HasMore();
+
+ // Move the index forward one.
+ void MoveNext() {
+ set_index(Smi::FromInt(Smi::cast(index())->value() + 1));
+ }
+
+ // Returns the current key of the iterator. This should only be called when
+ // |HasMore| returns true.
+ inline Object* CurrentKey();
+
private:
- // Transitions the iterator to the non obsolote backing store. This is a NOP
+ // Transitions the iterator to the non obsolete backing store. This is a NOP
// if the [table] is not obsolete.
void Transition();
@@ -10198,9 +10211,10 @@ class JSSetIterator: public OrderedHashTableIterator<JSSetIterator,
// Casting.
static inline JSSetIterator* cast(Object* obj);
- static Handle<Object> ValueForKind(
- Handle<JSSetIterator> iterator,
- int entry_index);
+ // Returns the iterator result value at the current |index| taking the |kind|
+ // into account. This should only be called when |HasMore| returns true.
+ static Handle<Object> CurrentIteratorResultValue(
+ Handle<JSSetIterator> iterator);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSSetIterator);
@@ -10217,9 +10231,14 @@ class JSMapIterator: public OrderedHashTableIterator<JSMapIterator,
// Casting.
static inline JSMapIterator* cast(Object* obj);
- static Handle<Object> ValueForKind(
- Handle<JSMapIterator> iterator,
- int entry_index);
+ // Returns the iterator result value at the current |index| taking the |kind|
+ // into account. This should only be called when |HasMore| returns true.
+ static Handle<Object> CurrentIteratorResultValue(
+ Handle<JSMapIterator> iterator);
+
+ // Returns the current value of the iterator. This should only be called when
+ // |HasMore| returns true.
+ inline Object* CurrentValue();
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSMapIterator);
« src/collection.js ('K') | « src/collection.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698