This optimization allows the interpreter to completely bypass a Ruby method call, which is a big win.
This optimization allows the interpreter to completely bypass a Ruby method call, which is a big win.
if (check_cfunc(ci->me, rb_obj_equal)) { return rb_obj_equal(recv, obj); }
and trusting the compiler to inline rb_obj_equal (or using inline), although I reckon you don't probably want rb_obj_equal to always be inlined.
The problem with just doing the rb_obj_equal call for everything is that if people override eql? in their Ruby code, you need to call that overridden method, instead.
The consequences of this decision mean that the comparison operator needs to be more complex.
Either that, or they never considered the compiler would most likely inline it.
Oddly enough, they do it for string comparisons: https://www.omniref.com/ruby/2.1.4/files/vm_insnhelper.c#lin...