diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-02 18:03:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-02 18:03:43 +0000 |
commit | e1966b31e90b1ef9bdadd0f08121762f70fa12e5 (patch) | |
tree | 52071a12b7e88fe0986bbf164d3f8c529f0b3150 /object.c | |
parent | 80359687b98b418a3d3fa4d49dd4addd3cc50e68 (diff) |
Get rid of calling to_f in rat2dbl_without_to_f
[Bug #15189]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -3421,17 +3421,16 @@ rb_str_to_dbl(VALUE str, int badcheck) #define big2dbl_without_to_f(x) rb_big2dbl(x) #define int2dbl_without_to_f(x) \ (FIXNUM_P(x) ? fix2dbl_without_to_f(x) : big2dbl_without_to_f(x)) +#define num2dbl_without_to_f(x) \ + (FIXNUM_P(x) ? fix2dbl_without_to_f(x) : \ + RB_TYPE_P(x, T_BIGNUM) ? big2dbl_without_to_f(x) : \ + (Check_Type(x, T_FLOAT), RFLOAT_VALUE(x))) static inline double rat2dbl_without_to_f(VALUE x) { VALUE num = rb_rational_num(x); VALUE den = rb_rational_den(x); - if (RB_INTEGER_TYPE_P(num) && RB_INTEGER_TYPE_P(den)) { - return int2dbl_without_to_f(num) / int2dbl_without_to_f(den); - } - else { - return NUM2DBL(num) / NUM2DBL(den); - } + return num2dbl_without_to_f(num) / num2dbl_without_to_f(den); } #define special_const_to_float(val, pre, post) \ |