3 ms·
I meant having something like: if (check_cfunc(ci->me, rb_obj_equal)) { return rb_obj_equal(recv, obj); } and trusting the compiler to inline rb_obj_equal (
by pgz 12y ago
I meant having something like:
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.
- masklinn 12y agoWell inlining this way is an optimisation which the compiler may or may not opt to apply, even after adding inlining hints. By manually inlining it they're introducing a little bit of trivial redundancy but I guess they can be certain there will be no indirect call. 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#line=860 https://www.omniref.com/ruby/2.1.4/files/vm_insnhelper.c#lin...
- timr 12y agoOh, sorry...wasn't clear. 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.
- saraid216 12y agoFYI, putting two spaces ahead of each line in a code block will wrap it in a pre-formatted tag. In case you didn't know.