summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-15 02:30:56 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-15 02:30:56 (GMT)
commita19830c42ce839ac1b4557cc30fe78757447f66c (patch)
treef182b4b8ba594787c8e16e87c3d585d3975b4e2c /range.c
parentc5196e249e5b5bb06a4f0b71a05bc1dd10b12342 (diff)
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
Diffstat (limited to 'range.c')
-rw-r--r--range.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/range.c b/range.c
index 8f48cd9..0dc0fb8 100644
--- a/range.c
+++ b/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);
}