Such moves are used when reallocating vectors that contain them, and could be used for more things later.
This change avoids an extra allocation when the data is not inlined.
Such moves are used when reallocating vectors that contain them, and could be used for more things later.
This change avoids an extra allocation when the data is not inlined.
utAck 7ad1126
minor nits:
#include "assert.h" in prevector.h that seems to be unused.is it necessary to kill the CScript copy constructor in this pull?
Yes, the presence of a custom copy constructor in CScript prevents the creation of a default move constructor or move assignment operator. I can add those as well, but given that the default copy constructor is perfectly appropriate, it's better to just pick that one, and get all default constructors and assignment operators.
you have an #include "assert.h" in prevector.h that seems to be unused.
Good catch.
258 | test.swap(); 259 | } 260 | + if (((r >> 15) % 16) == 8) { 261 | + test.copy(); 262 | + } 263 | + if (((r >> 15) % 32) == 18) {
trivial question, but what are these values representing?
Just things that are tested with certain percentage chance. The numbers here are chosen so that the copy/move/swap never occur at once (but it hardly matters).
[still trivial] @sipa any reason not to document those percentages? Or perhaps represent them in a non-bit shifting format? I find this to be the case often throughout, and I'm not the biggest fan of having to spend review time on determining the bit shifts in my head compared to higher level issues.
Trivial, but, prolific enough I thought I'd ask.
Code Review ACK 7ad1126215c0a527182840b2a98e5f83ddfad880.
nits:
267 | @@ -263,6 +268,10 @@ class prevector { 268 | return *this; 269 | } 270 | 271 | + prevector& operator=(prevector<N, T, Size, Diff>&& other) { 272 | + swap(other);
no return statement in function returning non-void.
Fixed.
@jonasschnelli Fair enough, there is no explicit test for CScript move, but I think we can rely on the C++ default constructors being correctly implemented in the compiler...
utACK other than the nits, looks familiar :)
tested ACK.
7 | @@ -8,6 +8,7 @@ 8 | #include <stdlib.h> 9 | #include <stdint.h> 10 | #include <string.h> 11 | +#include <assert.h>
Does assert.h need to be included here? This doesn't seem to add any assertions (ah, I see @jonasschnelli also mentions this).
Good point, fixed.
utACK efc0c4c, but see the nit
Such moves are used when reallocating vectors that contain them,
for example.
Nit fixed.