1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-11-16 07:28:30 +00:00
parent 288da355e3
commit c9b6a01435

View file

@ -543,11 +543,9 @@ range_bsearch(VALUE range)
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); \