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

ruby-changes:25619

From: nobu <ko1@a...>
Date: Fri, 16 Nov 2012 16:28:38 +0900 (JST)
Subject: [ruby-changes:25619] nobu:r37676 (trunk): range.c: compare signedness only

nobu	2012-11-16 16:28:30 +0900 (Fri, 16 Nov 2012)

  New Revision: 37676

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

  Log:
    range.c: compare signedness only
    
    * range.c (BSEARCH_CHECK): compare signedness only and relax an
      assumption of the result of rb_cmpint() which compilers cannot know.

  Modified files:
    trunk/range.c

Index: range.c
===================================================================
--- range.c	(revision 37675)
+++ range.c	(revision 37676)
@@ -543,11 +543,9 @@
 	    smaller = 0; \
 	} \
 	else if (rb_obj_is_kind_of(v, rb_cNumeric)) { \
-	    switch (rb_cmpint(rb_funcall(v, id_cmp, 1, INT2FIX(0)), v, INT2FIX(0))) { \
-		case 0: return val; \
-		case -1: smaller = 1; break; \
-		case 1: smaller = 0; \
-	    } \
+	    int cmp = rb_cmpint(rb_funcall(v, id_cmp, 1, INT2FIX(0)), v, INT2FIX(0)); \
+	    if (!cmp) return val; \
+	    smaller = cmp < 0; \
 	} \
 	else { \
 	    smaller = RTEST(v); \

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

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