summaryrefslogtreecommitdiffstats
path: root/Modules/_decimal
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2012-06-09 13:28:36 (GMT)
committerStefan Krah <skrah@bytereef.org>2012-06-09 13:28:36 (GMT)
commitafc0c77b421baf8ac2376e563dd9be25e1e1eb63 (patch)
tree30913c483ece7be9dc3825930041083a9d622b79 /Modules/_decimal
parent6e50b699ac60e5e7c3d92b0f5cbb96da618f3908 (diff)
downloadcpython-afc0c77b421baf8ac2376e563dd9be25e1e1eb63.zip
cpython-afc0c77b421baf8ac2376e563dd9be25e1e1eb63.tar.gz
cpython-afc0c77b421baf8ac2376e563dd9be25e1e1eb63.tar.bz2
Add one extra comparison to the _mpd_shortmul() case to avoid repetitive code.
Diffstat (limited to 'Modules/_decimal')
-rw-r--r--Modules/_decimal/libmpdec/mpdecimal.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c
index 1fc3cb9..40d33cf 100644
--- a/Modules/_decimal/libmpdec/mpdecimal.c
+++ b/Modules/_decimal/libmpdec/mpdecimal.c
@@ -5543,32 +5543,24 @@ _mpd_qmul(mpd_t *result, const mpd_t *a, const mpd_t *b,
if (small->len == 1) {
- if ((rdata = mpd_calloc(rsize, sizeof *rdata)) == NULL) {
- mpd_seterror(result, MPD_Malloc_error, status);
- return;
+ rdata = mpd_calloc(rsize, sizeof *rdata);
+ if (rdata != NULL) {
+ _mpd_shortmul(rdata, big->data, big->len, small->data[0]);
}
- _mpd_shortmul(rdata, big->data, big->len, small->data[0]);
}
else if (rsize <= 1024) {
rdata = _mpd_kmul(big->data, small->data, big->len, small->len, &rsize);
- if (rdata == NULL) {
- mpd_seterror(result, MPD_Malloc_error, status);
- return;
- }
}
else if (rsize <= 3*MPD_MAXTRANSFORM_2N) {
rdata = _mpd_fntmul(big->data, small->data, big->len, small->len, &rsize);
- if (rdata == NULL) {
- mpd_seterror(result, MPD_Malloc_error, status);
- return;
- }
}
else {
rdata = _mpd_kmul_fnt(big->data, small->data, big->len, small->len, &rsize);
- if (rdata == NULL) {
- mpd_seterror(result, MPD_Malloc_error, status); /* GCOV_UNLIKELY */
- return; /* GCOV_UNLIKELY */
- }
+ }
+
+ if (rdata == NULL) {
+ mpd_seterror(result, MPD_Malloc_error, status);
+ return;
}
if (mpd_isdynamic_data(result)) {