[Boost.Container] Performance of static_vector with default_init_t
Hi,
I'm constructing a static_vector
On 01/12/2016 14:09, dariomt@gmail.com wrote:
Hi,
I'm constructing a static_vector
(n, default_init). I was expecting the constructor call to vanish into just setting the start pointer and the size & capacity members (and verifying n<=N).
However, the profiler is showing some time spent in the loop inside uninitialized_default_init_alloc_n (boost/container/detail/utilities.hpp:678)
For a builtin type and default_init_t, why do we even need to invoke the allocator? Can't we just leave the memory uninitialized?
This is with Boost 1.55 and VS2008
Thanks in advance
It should be a no-op, but maybe it is not correctly inlined. With some compilers I still see some calls to uninitialized_default_init_alloc_n that disappear when the exception handling part is commented. It seems that the compiler can't simplify that function enough to make it a no-op. Could you please try with a more recent Boost version to see if the problem has improved a bit from your version? In any case please report a bug to see if something can be done, at least for POD types. Ion
participants (2)
-
dariomt@gmail.com
-
Ion Gaztañaga