ruby-changes:56757
From: Nobuyoshi <ko1@a...>
Date: Fri, 2 Aug 2019 11:41:04 +0900 (JST)
Subject: [ruby-changes:56757] Nobuyoshi Nakada: 6de61fb9ed (master): Expanded f_mod
https://git.ruby-lang.org/ruby.git/commit/?id=6de61fb9ed From 6de61fb9edf77d69e93cca8e4166b51b07c71c06 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 2 Aug 2019 11:19:29 +0900 Subject: Expanded f_mod diff --git a/rational.c b/rational.c index 7113e15..0f3cee7 100644 --- a/rational.c +++ b/rational.c @@ -43,13 +43,6 @@ static ID id_abs, id_idiv, id_integer_p, https://github.com/ruby/ruby/blob/trunk/rational.c#L43 static VALUE nurat_to_f(VALUE self); -#define binop(n,op) \ -inline static VALUE \ -f_##n(VALUE x, VALUE y)\ -{\ - return rb_funcall(x, (op), 1, y); \ -} - #define fun1(n) \ inline static VALUE \ f_##n(VALUE x)\ @@ -87,7 +80,13 @@ f_lt_p(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/rational.c#L80 #ifndef NDEBUG /* f_mod is used only in f_gcd defined when NDEBUG is not defined */ -binop(mod, '%') +inline static VALUE +f_mod(VALUE x, VALUE y) +{ + if (RB_INTEGER_TYPE_P(x)) + return rb_int_modulo(x, y); + return rb_funcall(x, '%', 1, y); +} #endif inline static VALUE -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/