From ed778c2a89258a8459e32aeee273a872a33ca421 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 14 Nov 2018 14:12:30 +0000 Subject: rational.c (nurat_div): use the dedicated function nurat_to_f git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- rational.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'rational.c') diff --git a/rational.c b/rational.c index 366e25ed79..47e67f128d 100644 --- a/rational.c +++ b/rational.c @@ -41,6 +41,8 @@ static ID id_abs, id_idiv, id_integer_p, #define f_inspect rb_inspect #define f_to_s rb_obj_as_string +static VALUE nurat_to_f(VALUE self); + #define binop(n,op) \ inline static VALUE \ f_##n(VALUE x, VALUE y)\ @@ -930,8 +932,7 @@ nurat_div(VALUE self, VALUE other) } } else if (RB_FLOAT_TYPE_P(other)) { - double d = nurat_to_double(self); - VALUE v = rb_float_new(d); + VALUE v = nurat_to_f(self); return rb_flo_div_flo(v, other); } else if (RB_TYPE_P(other, T_RATIONAL)) { @@ -954,8 +955,6 @@ nurat_div(VALUE self, VALUE other) } } -static VALUE nurat_to_f(VALUE self); - /* * call-seq: * rat.fdiv(numeric) -> float -- cgit v1.2.3