Chromium Code Reviews| Index: src/lookup.cc |
| diff --git a/src/lookup.cc b/src/lookup.cc |
| index 809c35e4a5339354bc9dd1bc7cb3e2e9530cbbfc..e545063172d498312a2d77c646599d68b20d29c8 100644 |
| --- a/src/lookup.cc |
| +++ b/src/lookup.cc |
| @@ -13,6 +13,43 @@ namespace v8 { |
| namespace internal { |
| +// static |
| +LookupIterator LookupIterator::PropertyOrElement(Isolate* isolate, |
| + Handle<Object> receiver, |
| + Handle<Object> name, |
|
Toon Verwaest
2015/09/30 13:02:33
What about calling this key?
Jakob Kummerow
2015/09/30 14:27:32
Done.
|
| + bool* success, |
| + Configuration configuration) { |
| + uint32_t index = 0; |
| + bool is_index = false; |
| + if (name->IsNumber()) { |
|
Toon Verwaest
2015/09/30 13:02:34
What about a slightly less branchy version:
uint3
Jakob Kummerow
2015/09/30 14:27:31
Nice simplification. Done.
|
| + if (name->ToArrayIndex(&index)) { |
| + is_index = true; |
| + } else { |
| + name = isolate->factory()->NumberToString(name); |
| + } |
| + } else { |
| + if (!Object::ToName(isolate, name).ToHandle(&name)) { |
| + DCHECK(isolate->has_pending_exception()); |
| + *success = false; |
| + // Return an unusable dummy. |
| + return LookupIterator(receiver, isolate->factory()->empty_string()); |
| + } |
| + DCHECK(name->IsName()); |
| + name = Name::Flatten(Handle<Name>::cast(name)); |
| + is_index = Handle<Name>::cast(name)->AsArrayIndex(&index); |
| + } |
| + *success = true; |
| + if (is_index) { |
| + return LookupIterator(isolate, receiver, index, configuration); |
| + } else { |
| + DCHECK(name->IsName()); |
| + LookupIterator it(receiver, Handle<Name>::cast(name), configuration); |
| + it.name_ = Handle<Name>::cast(name); |
|
Toon Verwaest
2015/09/30 13:02:33
You don't need to set the .name_ if you know it's
Jakob Kummerow
2015/09/30 14:27:32
Done.
(Not sure why that was there... probably an
|
| + return it; |
| + } |
| +} |
| + |
| + |
| void LookupIterator::Next() { |
| DCHECK_NE(JSPROXY, state_); |
| DCHECK_NE(TRANSITION, state_); |