ruby-changes:56758
From: Nobuyoshi <ko1@a...>
Date: Fri, 2 Aug 2019 11:41:05 +0900 (JST)
Subject: [ruby-changes:56758] Nobuyoshi Nakada: 19006b711d (master): Expanded f_quo
https://git.ruby-lang.org/ruby.git/commit/?id=19006b711d From 19006b711d8649b69d6f9dafad073a2f57201dd7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 2 Aug 2019 11:28:24 +0900 Subject: Expanded f_quo diff --git a/rational.c b/rational.c index 1dc08a0..fdaf4d6 100644 --- a/rational.c +++ b/rational.c @@ -1602,7 +1602,16 @@ f_ceil(VALUE x) https://github.com/ruby/ruby/blob/trunk/rational.c#L1602 } #define id_quo rb_intern("quo") -#define f_quo(x,y) rb_funcall((x), id_quo, 1, (y)) +static VALUE +f_quo(VALUE x, VALUE y) +{ + if (RB_INTEGER_TYPE_P(x)) + return rb_int_div(x, y); + if (RB_FLOAT_TYPE_P(x)) + return DBL2NUM(RFLOAT_VALUE(x) / RFLOAT_VALUE(y)); + + return rb_funcallv(x, id_quo, 1, &y); +} #define f_reciprocal(x) f_quo(ONE, (x)) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/