dtoa.c: Add shortcut if arguments are zero

This commit is contained in:
Nobuyoshi Nakada 2025-09-10 00:23:56 +09:00
parent 6a4222f475
commit 0887d82406
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465

View File

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