|
Boost Users : |
Subject: Re: [Boost-users] [Boost.Container] Performance of static_vector with default_init_t
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2016-12-04 17:35:55
On 01/12/2016 14:09, dariomt_at_[hidden] wrote:
> Hi,
>
> I'm constructing a static_vector<double,N>(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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net