Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit afc0c77

Browse files
author
Stefan Krah
committed
Add one extra comparison to the _mpd_shortmul() case to avoid repetitive code.
1 parent 6e50b69 commit afc0c77

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

Modules/_decimal/libmpdec/mpdecimal.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5543,32 +5543,24 @@ _mpd_qmul(mpd_t *result, const mpd_t *a, const mpd_t *b,
55435543

55445544

55455545
if (small->len == 1) {
5546-
if ((rdata = mpd_calloc(rsize, sizeof *rdata)) == NULL) {
5547-
mpd_seterror(result, MPD_Malloc_error, status);
5548-
return;
5546+
rdata = mpd_calloc(rsize, sizeof *rdata);
5547+
if (rdata != NULL) {
5548+
_mpd_shortmul(rdata, big->data, big->len, small->data[0]);
55495549
}
5550-
_mpd_shortmul(rdata, big->data, big->len, small->data[0]);
55515550
}
55525551
else if (rsize <= 1024) {
55535552
rdata = _mpd_kmul(big->data, small->data, big->len, small->len, &rsize);
5554-
if (rdata == NULL) {
5555-
mpd_seterror(result, MPD_Malloc_error, status);
5556-
return;
5557-
}
55585553
}
55595554
else if (rsize <= 3*MPD_MAXTRANSFORM_2N) {
55605555
rdata = _mpd_fntmul(big->data, small->data, big->len, small->len, &rsize);
5561-
if (rdata == NULL) {
5562-
mpd_seterror(result, MPD_Malloc_error, status);
5563-
return;
5564-
}
55655556
}
55665557
else {
55675558
rdata = _mpd_kmul_fnt(big->data, small->data, big->len, small->len, &rsize);
5568-
if (rdata == NULL) {
5569-
mpd_seterror(result, MPD_Malloc_error, status); /* GCOV_UNLIKELY */
5570-
return; /* GCOV_UNLIKELY */
5571-
}
5559+
}
5560+
5561+
if (rdata == NULL) {
5562+
mpd_seterror(result, MPD_Malloc_error, status);
5563+
return;
55725564
}
55735565

55745566
if (mpd_isdynamic_data(result)) {

0 commit comments

Comments
 (0)