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

Unified Diff: src/builtins.cc

Issue 1637753004: [es7] refactor and fix Object.values() / Object.entries() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix rebase Created 4 years, 10 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 | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 9cc26db23b622e67c63ea7f144ea109f93a495de..6f1fc0732b566b556082c13f3dc63a97751780a8 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -1753,22 +1753,10 @@ BUILTIN(ObjectValues) {
Handle<JSReceiver> receiver;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
Object::ToObject(isolate, object));
- Handle<FixedArray> keys;
+ Handle<FixedArray> values;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS,
- CONVERT_TO_STRING));
-
- for (int i = 0; i < keys->length(); ++i) {
- auto key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate));
- Handle<Object> value;
-
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT));
-
- keys->set(i, *value);
- }
-
- return *isolate->factory()->NewJSArrayWithElements(keys);
+ isolate, values, JSReceiver::GetOwnValues(receiver, ENUMERABLE_STRINGS));
+ return *isolate->factory()->NewJSArrayWithElements(values);
}
@@ -1778,26 +1766,11 @@ BUILTIN(ObjectEntries) {
Handle<JSReceiver> receiver;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
Object::ToObject(isolate, object));
- Handle<FixedArray> keys;
+ Handle<FixedArray> entries;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS,
- CONVERT_TO_STRING));
-
- for (int i = 0; i < keys->length(); ++i) {
- auto key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate));
- Handle<Object> value;
-
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT));
-
- auto entry_storage = isolate->factory()->NewUninitializedFixedArray(2);
- entry_storage->set(0, *key);
- entry_storage->set(1, *value);
- auto entry = isolate->factory()->NewJSArrayWithElements(entry_storage);
- keys->set(i, *entry);
- }
-
- return *isolate->factory()->NewJSArrayWithElements(keys);
+ isolate, entries,
+ JSReceiver::GetOwnEntries(receiver, ENUMERABLE_STRINGS));
+ return *isolate->factory()->NewJSArrayWithElements(entries);
}
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698