diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-08-02 11:19:29 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-08-02 11:26:51 +0900 |
commit | 6de61fb9edf77d69e93cca8e4166b51b07c71c06 (patch) | |
tree | 7365ddf31c3ec72d0fb89a99550d4e6cca5b1441 | |
parent | 8ba8ccc3ccdea943acbb12149578edd92e5164d4 (diff) | |
download | ruby-6de61fb9edf77d69e93cca8e4166b51b07c71c06.tar.gz |
Expanded f_mod
-rw-r--r-- | rational.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/rational.c b/rational.c index 7113e15e8e..0f3cee767a 100644 --- a/rational.c +++ b/rational.c @@ -43,13 +43,6 @@ static ID id_abs, id_idiv, id_integer_p, 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) #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 |