From b848f3c7e1f1d6ded0ccc1e045b58f5cdccfb9b5 Mon Sep 17 00:00:00 2001 From: mrkn Date: Fri, 11 Nov 2016 14:45:11 +0000 Subject: [PATCH] rational.c: optimize rational - integer * rational.c (nurat_sub): optimize rational - integer. Author: Tadashi Saito git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- rational.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rational.c b/rational.c index 5be862bd54..909a7fc397 100644 --- a/rational.c +++ b/rational.c @@ -782,9 +782,9 @@ nurat_sub(VALUE self, VALUE other) { get_dat1(self); - return f_addsub(self, - dat->num, dat->den, - other, ONE, '-'); + return f_rational_new_no_reduce2(CLASS_OF(self), + rb_int_minus(dat->num, rb_int_mul(other, dat->den)), + dat->den); } } else if (RB_TYPE_P(other, T_FLOAT)) {