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
Родитель 288da355e3
Коммит c9b6a01435
1 изменённых файлов: 3 добавлений и 5 удалений

Просмотреть файл

@ -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); \