ruby-changes:61017
From: Benoit <ko1@a...>
Date: Wed, 6 May 2020 07:28:33 +0900 (JST)
Subject: [ruby-changes:61017] e79e5e0b40 (master): Generalize the explanation of the side effect of the rb_equal() optimization
https://git.ruby-lang.org/ruby.git/commit/?id=e79e5e0b40 From e79e5e0b40d28d0a7eaa06dbfd6b7812bbea2d1e Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Wed, 6 May 2020 00:24:29 +0200 Subject: Generalize the explanation of the side effect of the rb_equal() optimization diff --git a/object.c b/object.c index 1e314e1..9830fef 100644 --- a/object.c +++ b/object.c @@ -154,8 +154,10 @@ case_equal(VALUE obj1, VALUE obj2) { https://github.com/ruby/ruby/blob/trunk/object.c#L154 * 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) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/