summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-05-06 00:24:29 +0200
committerBenoit Daloze <eregontp@gmail.com>2020-05-06 00:27:23 +0200
commite79e5e0b40d28d0a7eaa06dbfd6b7812bbea2d1e (patch)
tree09e39206f8efb9f610f1891130bde3d9ec064e81 /object.c
parent48d509cefc376df8af0ad0e08a09aecbd78f4f10 (diff)
Generalize the explanation of the side effect of the rb_equal() optimization
Diffstat (limited to 'object.c')
-rw-r--r--object.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/object.c b/object.c
index 1e314e14a9..9830feff10 100644
--- a/object.c
+++ b/object.c
@@ -154,8 +154,10 @@ case_equal(VALUE obj1, VALUE obj2) {
* identity check using using C's == (same as BasicObject#equal?).
* If that check fails, it calls #== dynamically.
* This optimization actually affects semantics,
- * as Float::NAN == Float::NAN is false,
- * but rb_equal(Float::NAN, Float::NAN) is true!
+ * because when #== returns false for the same object obj,
+ * rb_equal(obj, obj) would still return true.
+ * This happens for Float::NAN, where Float::NAN == Float::NAN
+ * is false, but rb_equal(Float::NAN, Float::NAN) is true.
*/
VALUE
rb_equal(VALUE obj1, VALUE obj2)