summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-17 10:46:21 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-17 10:46:21 (GMT)
commit989e07c0f2fa664a54e52a475c2fcc145f06539d (patch)
tree186a5a0e86de3ab43f0f641f41ba4c48e060f53b /range.c
parentd50ecb63ec02043865a4217af7e738f22ea6e8c7 (diff)
range.c: === by cover?
* range.c (range_eqq): switch `Range#===` to use `cover?` instead of `include?`. [Feature #14575] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/range.c b/range.c
index 917d24b..dcae2b2 100644
--- a/range.c
+++ b/range.c
@@ -1212,6 +1212,8 @@ range_inspect(VALUE range)
return rb_exec_recursive(inspect_range, range, 0);
}
+static VALUE range_include_internal(VALUE range, VALUE val);
+
/*
* call-seq:
* rng === obj -> true or false
@@ -1234,7 +1236,9 @@ range_inspect(VALUE range)
static VALUE
range_eqq(VALUE range, VALUE val)
{
- return rb_funcall(range, rb_intern("include?"), 1, val);
+ VALUE ret = range_include_internal(range, val);
+ if (ret != Qundef) return ret;
+ return r_cover_p(range, RANGE_BEG(range), RANGE_END(range), val);
}
@@ -1255,6 +1259,14 @@ range_eqq(VALUE range, VALUE val)
static VALUE
range_include(VALUE range, VALUE val)
{
+ VALUE ret = range_include_internal(range, val);
+ if (ret != Qundef) return ret;
+ return rb_call_super(1, &val);
+}
+
+static VALUE
+range_include_internal(VALUE range, VALUE val)
+{
VALUE beg = RANGE_BEG(range);
VALUE end = RANGE_END(range);
int nv = FIXNUM_P(beg) || FIXNUM_P(end) ||
@@ -1277,8 +1289,7 @@ range_include(VALUE range, VALUE val)
return Qfalse;
}
}
- /* TODO: ruby_frame->this_func = rb_intern("include?"); */
- return rb_call_super(1, &val);
+ return Qundef;
}