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

Unified Diff: src/objects.cc

Issue 24360017: Expose SameValue equality comparison algorithm (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 7 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 | « src/api.cc ('k') | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 2ed417fa3c409aaeb00bcf04c36dd8d21ece488c..169307fb8e077c8cb4513f6f9fdaa489ac2dc26d 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -1005,8 +1005,11 @@ bool Object::SameValue(Object* other) {
if (IsNumber() && other->IsNumber()) {
double this_value = Number();
double other_value = other->Number();
- return (this_value == other_value) ||
- (std::isnan(this_value) && std::isnan(other_value));
+ bool equal = this_value == other_value;
+ // SameValue(NaN, NaN) is true.
+ if (!equal) return std::isnan(this_value) && std::isnan(other_value);
+ // SameValue(0.0, -0.0) is false.
+ return (this_value != 0) || ((1 / this_value) == (1 / other_value));
yusukesuzuki 2013/09/24 12:58:26 According to the comment of Object::SameValue in o
}
if (IsString() && other->IsString()) {
return String::cast(this)->Equals(String::cast(other));
« no previous file with comments | « src/api.cc ('k') | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698