1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
mrkn 2016-11-11 14:45:11 +00:00
parent d028d6984f
commit b848f3c7e1

View file

@ -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)) {