Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index fefdc5be48dde724d2eeff54368985392a6dc7b3..56699e9fad4b781d026faf88c6a8c8f326b95031 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -15096,10 +15096,9 @@ int JSObject::GetOwnPropertyNames(FixedArray* storage, int index, |
} |
-int JSObject::CollectOwnPropertyNames(KeyAccumulator* keys, |
- PropertyAttributes filter) { |
+void JSObject::CollectOwnPropertyNames(KeyAccumulator* keys, |
+ PropertyAttributes filter) { |
if (HasFastProperties()) { |
- int nof_keys = keys->length(); |
int real_size = map()->NumberOfOwnDescriptors(); |
Handle<DescriptorArray> descs(map()->instance_descriptors()); |
for (int i = 0; i < real_size; i++) { |
@@ -15108,11 +15107,10 @@ int JSObject::CollectOwnPropertyNames(KeyAccumulator* keys, |
if (key->FilterKey(filter)) continue; |
keys->AddKey(key); |
} |
- return nof_keys - keys->length(); |
} else if (IsJSGlobalObject()) { |
- return global_dictionary()->CollectKeysTo(keys, filter); |
+ global_dictionary()->CollectKeysTo(keys, filter); |
} else { |
- return property_dictionary()->CollectKeysTo(keys, filter); |
+ property_dictionary()->CollectKeysTo(keys, filter); |
} |
} |
@@ -16903,10 +16901,13 @@ int Dictionary<Derived, Shape, Key>::CopyKeysTo( |
template <typename Derived, typename Shape, typename Key> |
-int Dictionary<Derived, Shape, Key>::CollectKeysTo(KeyAccumulator* keys, |
- PropertyAttributes filter) { |
+void Dictionary<Derived, Shape, Key>::CollectKeysTo(KeyAccumulator* keys, |
+ PropertyAttributes filter) { |
int capacity = this->Capacity(); |
- int keyLength = keys->length(); |
+ Handle<FixedArray> array = |
+ keys->isolate()->factory()->NewFixedArray(capacity); |
Camillo Bruni
2015/11/17 10:02:52
I think NumberOfElements() would be better here no
|
+ int array_size = 0; |
+ |
for (int i = 0; i < capacity; i++) { |
Object* k = this->KeyAt(i); |
if (!this->IsKey(k) || k->FilterKey(filter)) continue; |
@@ -16914,9 +16915,16 @@ int Dictionary<Derived, Shape, Key>::CollectKeysTo(KeyAccumulator* keys, |
PropertyDetails details = this->DetailsAt(i); |
PropertyAttributes attr = details.attributes(); |
if ((attr & filter) != 0) continue; |
- keys->AddKey(k); |
+ array->set(array_size++, Smi::FromInt(i)); |
+ } |
+ |
+ EnumIndexComparator<Derived> cmp(static_cast<Derived*>(this)); |
+ Smi** start = reinterpret_cast<Smi**>(array->GetFirstElementAddress()); |
+ std::sort(start, start + array_size, cmp); |
+ for (int i = 0; i < array_size; i++) { |
+ int index = Smi::cast(array->get(i))->value(); |
+ keys->AddKey(this->KeyAt(index)); |
} |
- return keyLength - keys->length(); |
} |