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

Unified Diff: src/keys.cc

Issue 1989263002: [keys] KeyAccumulator cleanups (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « src/keys.h ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/keys.cc
diff --git a/src/keys.cc b/src/keys.cc
index 32e1bb3f63f36e4889f2545969e025a5ac704f4c..17270eb1bede8711201731f3010c02b16a2cb2ed 100644
--- a/src/keys.cc
+++ b/src/keys.cc
@@ -22,6 +22,33 @@ KeyAccumulator::~KeyAccumulator() {
}
}
+namespace {
+
+static bool ContainsOnlyValidKeys(Handle<FixedArray> array) {
+ int len = array->length();
+ for (int i = 0; i < len; i++) {
+ Object* e = array->get(i);
+ if (!(e->IsName() || e->IsNumber())) return false;
+ }
+ return true;
+}
+
+} // namespace
+
+MaybeHandle<FixedArray> KeyAccumulator::GetKeys(
+ Handle<JSReceiver> object, KeyCollectionType type, PropertyFilter filter,
+ GetKeysConversion keys_conversion, bool filter_proxy_keys) {
+ USE(ContainsOnlyValidKeys);
+ Isolate* isolate = object->GetIsolate();
+ KeyAccumulator accumulator(isolate, type, filter);
+ accumulator.set_filter_proxy_keys(filter_proxy_keys);
+ MAYBE_RETURN(accumulator.CollectKeys(object, object),
+ MaybeHandle<FixedArray>());
+ Handle<FixedArray> keys = accumulator.GetKeys(keys_conversion);
+ DCHECK(ContainsOnlyValidKeys(keys));
+ return keys;
+}
+
Handle<FixedArray> KeyAccumulator::GetKeys(GetKeysConversion convert) {
if (length_ == 0) {
return isolate_->factory()->empty_fixed_array();
@@ -568,7 +595,7 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysFast(
MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysSlow(
GetKeysConversion convert) {
- return JSReceiver::GetKeys(receiver_, type_, ENUMERABLE_STRINGS, KEEP_NUMBERS,
+ return JSReceiver::GetKeys(receiver_, type_, filter_, KEEP_NUMBERS,
filter_proxy_keys_);
}
« no previous file with comments | « src/keys.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698