rational.c: short circuit optimization
* rational.c (nurat_reduce): short circuit when arguments are ONE, nothing is needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
14b3dc1ec4
commit
a3fb17f3a0
@ -488,7 +488,9 @@ nurat_canonicalize(VALUE *num, VALUE *den)
|
||||
static void
|
||||
nurat_reduce(VALUE *x, VALUE *y)
|
||||
{
|
||||
VALUE gcd = f_gcd(*x, *y);
|
||||
VALUE gcd;
|
||||
if (*x == ONE || *y == ONE) return;
|
||||
gcd = f_gcd(*x, *y);
|
||||
*x = f_idiv(*x, gcd);
|
||||
*y = f_idiv(*y, gcd);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user