mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* bignum.c (bigdivrem): Specialized implementation added for
nx == 2 && ny == 2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e4b0852ae4
commit
7a9aeb33db
2 changed files with 26 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Jul 29 00:11:49 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* bignum.c (bigdivrem): Specialized implementation added for
|
||||
nx == 2 && ny == 2
|
||||
|
||||
Sun Jul 28 20:28:41 2013 Masaki Matsushita <glass.saga@gmail.com>
|
||||
|
||||
* io.c (io_getpartial): use rb_str_locktmp_ensure().
|
||||
|
|
21
bignum.c
21
bignum.c
|
@ -5399,6 +5399,27 @@ bigdivrem(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
|
|||
if (divp) *divp = z;
|
||||
return Qnil;
|
||||
}
|
||||
if (nx == 2 && ny == 2) {
|
||||
BDIGIT_DBL x0 = xds[0] | BIGUP(xds[1]);
|
||||
BDIGIT_DBL y0 = yds[0] | BIGUP(yds[1]);
|
||||
BDIGIT_DBL q0 = x0 / y0;
|
||||
BDIGIT_DBL r0 = x0 % y0;
|
||||
if (divp) {
|
||||
z = bignew(bdigit_roomof(sizeof(BDIGIT_DBL)), RBIGNUM_SIGN(x)==RBIGNUM_SIGN(y));
|
||||
zds = BDIGITS(z);
|
||||
zds[0] = BIGLO(q0);
|
||||
zds[1] = BIGLO(BIGDN(q0));
|
||||
*divp = z;
|
||||
}
|
||||
if (modp) {
|
||||
z = bignew(bdigit_roomof(sizeof(BDIGIT_DBL)), RBIGNUM_SIGN(x));
|
||||
zds = BDIGITS(z);
|
||||
zds[0] = BIGLO(r0);
|
||||
zds[1] = BIGLO(BIGDN(r0));
|
||||
*modp = z;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
if (BDIGIT_MSB(yds[ny-1]) == 0) {
|
||||
/* Make yds modifiable. */
|
||||
|
|
Loading…
Add table
Reference in a new issue