1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

range.c: call range_include directly if possible

* range.c (range_eqq): trivial optimization to jump to
  range_include directly if the method is not redefined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-08-15 02:30:56 +00:00
parent c5196e249e
commit a19830c42c

View file

@ -23,6 +23,7 @@ static ID id_beg, id_end, id_excl, id_integer_p, id_div;
#define id_succ idSucc
static VALUE r_cover_p(VALUE, VALUE, VALUE, VALUE);
static VALUE range_include(VALUE range, VALUE val);
#define RANGE_BEG(r) (RSTRUCT(r)->as.ary[0])
#define RANGE_END(r) (RSTRUCT(r)->as.ary[1])
@ -1134,7 +1135,12 @@ range_inspect(VALUE range)
static VALUE
range_eqq(VALUE range, VALUE val)
{
return rb_funcall(range, rb_intern("include?"), 1, val);
ID pred;
CONST_ID(pred, "include?");
if (rb_method_basic_definition_p(RBASIC_CLASS(range), pred)) {
return range_include(range, val);
}
return rb_funcall(range, pred, 1, val);
}