Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index 2c8009e1d3cd80ccadb86940476edb47a4e148be..4dcd7a04348c94b7c47620efad6c9505f0055643 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -3022,8 +3022,17 @@ int32_t Value::Int32Value() const { |
| bool Value::Equals(Handle<Value> that) const { |
| - i::Isolate* isolate = i::Isolate::Current(); |
| i::Handle<i::Object> obj = Utils::OpenHandle(this, true); |
| + i::Handle<i::Object> other = Utils::OpenHandle(*that); |
| + if (obj->IsSmi() && other->IsSmi()) { |
| + return obj->Number() == other->Number(); |
| + } |
| + i::Isolate* isolate = NULL; |
| + if (!obj->IsSmi()) { |
| + isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
| + } else { |
| + isolate = i::HeapObject::cast(*other)->GetIsolate(); |
| + } |
|
Sven Panne
2014/11/06 07:29:35
Shorter and more readable version:
i::Object* ho
|
| if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(), |
| "v8::Value::Equals()", |
| "Reading from empty handle")) { |
| @@ -3031,7 +3040,6 @@ bool Value::Equals(Handle<Value> that) const { |
| } |
| LOG_API(isolate, "Equals"); |
| ENTER_V8(isolate); |
| - i::Handle<i::Object> other = Utils::OpenHandle(*that); |
| // If both obj and other are JSObjects, we'd better compare by identity |
| // immediately when going into JS builtin. The reason is Invoke |
| // would overwrite global object receiver with global proxy. |
| @@ -3050,15 +3058,18 @@ bool Value::Equals(Handle<Value> that) const { |
| bool Value::StrictEquals(Handle<Value> that) const { |
| - i::Isolate* isolate = i::Isolate::Current(); |
| i::Handle<i::Object> obj = Utils::OpenHandle(this, true); |
| + i::Handle<i::Object> other = Utils::OpenHandle(*that); |
| + if (obj->IsSmi()) { |
| + return other->IsNumber() && obj->Number() == other->Number(); |
| + } |
| + i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
| if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(), |
| "v8::Value::StrictEquals()", |
| "Reading from empty handle")) { |
| return false; |
| } |
| LOG_API(isolate, "StrictEquals"); |
| - i::Handle<i::Object> other = Utils::OpenHandle(*that); |
| // Must check HeapNumber first, since NaN !== NaN. |
| if (obj->IsHeapNumber()) { |
| if (!other->IsNumber()) return false; |