ruby-changes:53511
From: nobu <ko1@a...>
Date: Wed, 14 Nov 2018 23:12:35 +0900 (JST)
Subject: [ruby-changes:53511] nobu:r65727 (trunk): rational.c (nurat_div): use the dedicated function nurat_to_f
nobu 2018-11-14 23:12:30 +0900 (Wed, 14 Nov 2018) New Revision: 65727 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65727 Log: rational.c (nurat_div): use the dedicated function nurat_to_f Modified files: trunk/rational.c Index: rational.c =================================================================== --- rational.c (revision 65726) +++ rational.c (revision 65727) @@ -41,6 +41,8 @@ static ID id_abs, id_idiv, id_integer_p, https://github.com/ruby/ruby/blob/trunk/rational.c#L41 #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) https://github.com/ruby/ruby/blob/trunk/rational.c#L932 } } 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) https://github.com/ruby/ruby/blob/trunk/rational.c#L955 } } -static VALUE nurat_to_f(VALUE self); - /* * call-seq: * rat.fdiv(numeric) -> float -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/