diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-05 03:51:09 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-05 03:51:09 +0000 |
commit | e29e4b55ab79bd18550b11ce7d9cf94deca365be (patch) | |
tree | 2bdb6ff43327712631230572714711575d54434e /range.c | |
parent | 1677cbce9d7c72cca83d1b7d48cb85a17e74abcc (diff) | |
download | ruby-e29e4b55ab79bd18550b11ce7d9cf94deca365be.tar.gz |
* range.c: Use div instead of / for bsearch
* test/ruby/test_range.rb: Test showing bug when requiring mathn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r-- | range.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -20,7 +20,7 @@ #include <math.h> VALUE rb_cRange; -static ID id_cmp, id_succ, id_beg, id_end, id_excl, id_integer_p; +static ID id_cmp, id_succ, id_beg, id_end, id_excl, id_integer_p, id_div; #define RANGE_BEG(r) (RSTRUCT(r)->as.ary[0]) #define RANGE_END(r) (RSTRUCT(r)->as.ary[1]) @@ -656,7 +656,7 @@ range_bsearch(VALUE range) org_high = high; while (rb_cmpint(rb_funcall(low, id_cmp, 1, high), low, high) < 0) { - mid = rb_funcall(rb_funcall(high, '+', 1, low), '/', 1, INT2FIX(2)); + mid = rb_funcall(rb_funcall(high, '+', 1, low), id_div, 1, INT2FIX(2)); BSEARCH_CHECK(mid); if (smaller) { high = mid; @@ -1311,6 +1311,7 @@ Init_Range(void) id_end = rb_intern("end"); id_excl = rb_intern("excl"); id_integer_p = rb_intern("integer?"); + id_div = rb_intern("div"); rb_cRange = rb_struct_define_without_accessor( "Range", rb_cObject, range_alloc, |