|
|
Le 13/08/2016 à 23:24, clipka a écrit :
> Also, although it would theoretically be possible to replace the data
> structure with a variable-sized one, any attempts at doing so have so
> far resulted in severely degraded performance.
To avoid reallocation at each new element, you can reserve() some containers like
vector<>.
Until the reserved number of element is reached, no more reallocation. But there is no
signaling of the reservation being full, so after that you're back to the
reallocation.
But vector<> has one constraint: the elements are contiguous. Something that is not
always needed.
The less light-hearted programmers might even replace the default allocator for
something totally different.
But gaining over the traditional malloc is hard, very hard.
Post a reply to this message
|
|