ruby-changes:45225
From: nobu <ko1@a...>
Date: Tue, 10 Jan 2017 22:37:43 +0900 (JST)
Subject: [ruby-changes:45225] nobu:r57298 (trunk): rational.c: f_idiv
nobu 2017-01-10 22:37:34 +0900 (Tue, 10 Jan 2017) New Revision: 57298 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57298 Log: rational.c: f_idiv * rational.c (f_idiv): call rb_int_idiv directly if possible. Modified files: trunk/rational.c Index: rational.c =================================================================== --- rational.c (revision 57297) +++ rational.c (revision 57298) @@ -53,13 +53,6 @@ f_##n(VALUE x)\ https://github.com/ruby/ruby/blob/trunk/rational.c#L53 return rb_funcall(x, id_##n, 0);\ } -#define fun2(n) \ -inline static VALUE \ -f_##n(VALUE x, VALUE y)\ -{\ - return rb_funcall(x, id_##n, 1, y);\ -} - inline static VALUE f_add(VALUE x, VALUE y) { @@ -154,7 +147,13 @@ f_eqeq_p(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/rational.c#L147 return (int)rb_equal(x, y); } -fun2(idiv) +inline static VALUE +f_idiv(VALUE x, VALUE y) +{ + if (RB_INTEGER_TYPE_P(x)) + return rb_int_idiv(x, y); + return rb_funcall(x, id_idiv, 1, y); +} #define f_expt10(x) rb_int_pow(INT2FIX(10), x) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/