[前][次][番号順一覧][スレッド一覧]

ruby-changes:38417

From: nobu <ko1@a...>
Date: Fri, 15 May 2015 18:06:08 +0900 (JST)
Subject: [ruby-changes:38417] nobu:r50498 (trunk): range.c: r_cover_p

nobu	2015-05-15 18:05:57 +0900 (Fri, 15 May 2015)

  New Revision: 50498

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50498

  Log:
    range.c: r_cover_p
    
    * range.c (r_cover_p): extract from range_cover and share with
      range_include.

  Modified files:
    trunk/range.c
Index: range.c
===================================================================
--- range.c	(revision 50497)
+++ range.c	(revision 50498)
@@ -22,6 +22,8 @@ static ID id_beg, id_end, id_excl, id_in https://github.com/ruby/ruby/blob/trunk/range.c#L22
 #define id_cmp idCmp
 #define id_succ idSucc
 
+static VALUE r_cover_p(VALUE, VALUE, VALUE, VALUE);
+
 #define RANGE_BEG(r) (RSTRUCT(r)->as.ary[0])
 #define RANGE_END(r) (RSTRUCT(r)->as.ary[1])
 #define RANGE_EXCL(r) (RSTRUCT(r)->as.ary[2])
@@ -1176,17 +1178,7 @@ range_include(VALUE range, VALUE val) https://github.com/ruby/ruby/blob/trunk/range.c#L1178
     if (nv ||
 	!NIL_P(rb_check_to_integer(beg, "to_int")) ||
 	!NIL_P(rb_check_to_integer(end, "to_int"))) {
-	if (r_le(beg, val)) {
-	    if (EXCL(range)) {
-		if (r_lt(val, end))
-		    return Qtrue;
-	    }
-	    else {
-		if (r_le(val, end))
-		    return Qtrue;
-	    }
-	}
-	return Qfalse;
+	return r_cover_p(range, beg, end, val);
     }
     else if (RB_TYPE_P(beg, T_STRING) && RB_TYPE_P(end, T_STRING) &&
 	     RSTRING_LEN(beg) == 1 && RSTRING_LEN(end) == 1) {
@@ -1234,6 +1226,12 @@ range_cover(VALUE range, VALUE val) https://github.com/ruby/ruby/blob/trunk/range.c#L1226
 
     beg = RANGE_BEG(range);
     end = RANGE_END(range);
+    return r_cover_p(range, beg, end, val);
+}
+
+static VALUE
+r_cover_p(VALUE range, VALUE beg, VALUE end, VALUE val)
+{
     if (r_le(beg, val)) {
 	if (EXCL(range)) {
 	    if (r_lt(val, end))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]