Skip to content

Commit 337219a

Browse files
committed
Remove reallocate logic in VpMult only used for VpSqrt
1 parent 43ad5c9 commit 337219a

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

ext/bigdecimal/bigdecimal.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4976,7 +4976,6 @@ VpMult(Real *c, Real *a, Real *b)
49764976
size_t ind_as, ind_ae, ind_bs;
49774977
DECDIG carry;
49784978
DECDIG_DBL s;
4979-
Real *w;
49804979

49814980
if (!VpIsDefOP(c, a, b, OP_SW_MULT)) return 0; /* No significant digit */
49824981

@@ -4996,29 +4995,19 @@ VpMult(Real *c, Real *a, Real *b)
49964995
}
49974996
if (b->Prec > a->Prec) {
49984997
/* Adjust so that digits(a)>digits(b) */
4999-
w = a;
4998+
Real *w = a;
50004999
a = b;
50015000
b = w;
50025001
}
5003-
w = NULL;
50045002
MxIndA = a->Prec - 1;
50055003
MxIndB = b->Prec - 1;
50065004
MxIndAB = a->Prec + b->Prec - 1;
50075005

5008-
// Only VpSqrt calls VpMult with insufficient precision
5009-
if (c->MaxPrec < VPMULT_RESULT_PREC(a, b)) {
5010-
w = c;
5011-
c = NewZeroNolimit(1, VPMULT_RESULT_PREC(a, b) * BASE_FIG);
5012-
}
5013-
50145006
/* set LHSV c info */
50155007

50165008
c->exponent = a->exponent; /* set exponent */
50175009
VpSetSign(c, VpGetSign(a) * VpGetSign(b)); /* set sign */
5018-
if (!AddExponent(c, b->exponent)) {
5019-
if (w) rbd_free_struct(c);
5020-
return 0;
5021-
}
5010+
if (!AddExponent(c, b->exponent)) return 0;
50225011
carry = 0;
50235012
nc = ind_c = MxIndAB;
50245013
memset(c->frac, 0, (nc + 1) * sizeof(DECDIG)); /* Initialize c */
@@ -5066,11 +5055,6 @@ VpMult(Real *c, Real *a, Real *b)
50665055
}
50675056
}
50685057
VpNmlz(c);
5069-
if (w != NULL) { /* free work variable */
5070-
VpAsgn(w, c, 10);
5071-
rbd_free_struct(c);
5072-
c = w;
5073-
}
50745058

50755059
Exit:
50765060
return c->Prec*BASE_FIG;

0 commit comments

Comments
 (0)