[RFC][PATCH] mini-gmp: move memory allocation out of loops

Marco Bodrato bodrato at mail.dm.unipi.it
Sat Feb 10 20:19:27 UTC 2018


Il Sab, 10 Febbraio 2018 7:07 pm, Ilya Yanok ha scritto:
> thanks a lot for your comments.

Thank you for spotting a function that was not as efficient as it could
(easily) be :-)
Keep on the good work!-)

> On Sat, Feb 10, 2018 at 6:11 PM Niels Möller <nisse at lysator.liu.se> wrote:
>> Note that remainder is always two limbs. So reusing qp area would be
>> more natural (but unlike np, qp == NULL is allowed). So not sure what

> Correct me if I'm wrong, but I think in mpn_div_qr_2_preinv, unlike
> mpn_div_qr_1_preinv, (array pointed by) qp can be smaller than np, so

I agree.

>> Maybe the below is a reasonable way (note that the #if:ed out
>> mpn_div_qr_2 can't be easily supported with this interface).

I think that static helper functions must be as simple and efficient as
possible. They do not need to be flexible, if not needed by the exported
function calling them.

We will change the helper when we need it.



More information about the gmp-devel mailing list