зеркало из https://github.com/github/ruby.git
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:
Родитель
c5196e249e
Коммит
a19830c42c
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче