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

Unified Diff: src/api.cc

Issue 1375943002: Add LookupIterator constructor for arbitrary Object keys (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 5 years, 3 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/lookup.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 0b99743a9cc5c9a527718f67a25cfc46ba321e3f..d0859663ef34111effb0fd1df7d7e21d5ec53aa6 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3526,20 +3526,12 @@ static i::MaybeHandle<i::Object> DefineObjectProperty(
i::Handle<i::JSObject> js_object, i::Handle<i::Object> key,
i::Handle<i::Object> value, PropertyAttributes attrs) {
i::Isolate* isolate = js_object->GetIsolate();
- // Check if the given key is an array index.
- uint32_t index = 0;
- if (key->ToArrayIndex(&index)) {
- return i::JSObject::SetOwnElementIgnoreAttributes(js_object, index, value,
- attrs);
- }
-
- i::Handle<i::Name> name;
- ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, name,
- i::Object::ToName(isolate, key),
- i::MaybeHandle<i::Object>());
+ bool success = false;
+ i::LookupIterator it = i::LookupIterator::PropertyOrElement(
+ isolate, js_object, key, &success, i::LookupIterator::OWN);
+ if (!success) return i::MaybeHandle<i::Object>();
- return i::JSObject::DefinePropertyOrElementIgnoreAttributes(js_object, name,
- value, attrs);
+ return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs);
}
« no previous file with comments | « no previous file | src/lookup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698