MRI: use RB_TYPE_P() instead of rb_type() #57
No reviewers
Labels
No Label
RGSS accuracy
bug
compilation
discussion
documentation
duplicate
enhancement
invalid
performance issue
port request
question
ruby incompatibility
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: MapleShrine/mkxp#57
Loading…
Reference in New Issue
No description provided.
Delete Branch "mri-use-rb_type_p-instead-of-rb_type"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Nothing important, but I'm currently fixing some issues with
rb_get_args
and I've noticed that almost everywhereRB_TYPE_P
(which selects the right comparison) can be used instead ofrb_type
(which most probably doesn't).Thanks, this is fine, but what do you mean by "rb_type most probably doesn't select the right comparison"?
I'm not good with words. It supports an optimizing compiler in selecting the right comparison:
7df9a77da1/include/ruby/ruby.h (L1605-L1613)
So if you write
RB_TYPE_P(obj, T_STRING)
everything else than(!SPECIAL_CONST_P(obj) && BUILTIN_TYPE(obj) == (T_STRING))
gets eliminated because it's dead code.rb_type
sometimes doesn't even get inlined.I was aware
rb_type
was a function, the way it looked to me it seemed every optimizing compiler would reduce it into more or less howRB_TYPE_P
looks (ie. a bunch of inline cmp/branches).