speed of mpz_odd_p and lazy allocation

Marc Glisse marc.glisse at inria.fr
Mon Aug 20 21:43:23 CEST 2012


On Mon, 20 Aug 2012, Gabriel Dos Reis wrote:

> On Mon, Aug 20, 2012 at 2:24 PM, Marc Glisse <marc.glisse at inria.fr> wrote:
>> This is perfectly fine, it is optimization n°2 for the case where the move
>> constructor throws, but the move assignment (swap) doesn't. It is unclear
>> whether this optimization will be implemented by any vendor. If mpz_init
>> allocates, it remains slow.
>
> What would be the basis for a vendor to assume that
> the elements from the old vector should be assigned
> as opposed to being copy constructed into the new vector?

Are you asking if it is legal to implement reserve() this way (after 
detecting the right constructors/operators)? Or how we can guess if this 
"optimization" is really an improvement?

-- 
Marc Glisse


More information about the gmp-devel mailing list