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:
parent
c5196e249e
commit
a19830c42c
1 changed files with 7 additions and 1 deletions
8
range.c
8
range.c
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue