u3: refactors gmp initialization in u3r_mp()

This commit is contained in:
Joe Bryan 2021-04-22 17:34:49 -07:00
parent 0681c9a477
commit 45ef57ab1a

View File

@ -1205,16 +1205,11 @@ u3r_mp(mpz_t a_mp,
else {
u3a_atom* b_u = u3a_to_ptr(b);
c3_w len_w = b_u->len_w;
c3_d bit_d = (c3_d)len_w << 5;
// avoid reallocation on import, if possible
//
if ( (len_w >> 27) ) {
mpz_init(a_mp);
}
else {
mpz_init2(a_mp, len_w << 5);
}
mpz_init2(a_mp, (c3_w)c3_min(bit_d, UINT32_MAX));
mpz_import(a_mp, len_w, -1, sizeof(c3_w), 0, 0, b_u->buf_w);
}
}