mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
dtoa.c: Add shortcut if arguments are zero
This commit is contained in:
parent
6a4222f475
commit
0887d82406
@ -699,6 +699,8 @@ i2b(int i)
|
||||
return b;
|
||||
}
|
||||
|
||||
#define Bzero_p(b) (!(b)->x[0] && (b)->wds <= 1)
|
||||
|
||||
static Bigint *
|
||||
mult(Bigint *a, Bigint *b)
|
||||
{
|
||||
@ -715,6 +717,13 @@ mult(Bigint *a, Bigint *b)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (Bzero_p(a) || Bzero_p(b)) {
|
||||
c = Balloc(0);
|
||||
c->wds = 1;
|
||||
c->x[0] = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
if (a->wds < b->wds) {
|
||||
c = a;
|
||||
a = b;
|
||||
@ -862,6 +871,8 @@ lshift(Bigint *b, int k)
|
||||
Bigint *b1;
|
||||
ULong *x, *x1, *xe, z;
|
||||
|
||||
if (!k || Bzero_p(b)) return b;
|
||||
|
||||
#ifdef Pack_32
|
||||
n = k >> 5;
|
||||
#else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user