Skip to content

Commit 0887d82

Browse files
committed
dtoa.c: Add shortcut if arguments are zero
1 parent 6a4222f commit 0887d82

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

missing/dtoa.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,8 @@ i2b(int i)
699699
return b;
700700
}
701701

702+
#define Bzero_p(b) (!(b)->x[0] && (b)->wds <= 1)
703+
702704
static Bigint *
703705
mult(Bigint *a, Bigint *b)
704706
{
@@ -715,6 +717,13 @@ mult(Bigint *a, Bigint *b)
715717
#endif
716718
#endif
717719

720+
if (Bzero_p(a) || Bzero_p(b)) {
721+
c = Balloc(0);
722+
c->wds = 1;
723+
c->x[0] = 0;
724+
return c;
725+
}
726+
718727
if (a->wds < b->wds) {
719728
c = a;
720729
a = b;
@@ -862,6 +871,8 @@ lshift(Bigint *b, int k)
862871
Bigint *b1;
863872
ULong *x, *x1, *xe, z;
864873

874+
if (!k || Bzero_p(b)) return b;
875+
865876
#ifdef Pack_32
866877
n = k >> 5;
867878
#else

0 commit comments

Comments
 (0)