summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-11 14:45:11 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-11 14:45:11 +0000
commitb848f3c7e1f1d6ded0ccc1e045b58f5cdccfb9b5 (patch)
treec2b2300b2317f283951297da56d199e4b7d32917
parentd028d6984fe23887348d2a63cb308d8b0761c84f (diff)
rational.c: optimize rational - integer
* rational.c (nurat_sub): optimize rational - integer. Author: Tadashi Saito <tad.a.digger@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--rational.c6
1 files 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)) {