|
Boost Users : |
Subject: Re: [Boost-users] large variant performance compared (50 elements)
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-01-09 11:20:17
AMDG
On 1/9/2011 5:37 AM, Mathias Gaunard wrote:
> On 08/01/2011 23:47, Steven Watanabe wrote:
>>> Would this be a change that is candidate for a future boost release?
>>> And are you able to do just that?
>>
>> I've committed it to the trunk.
>> https://svn.boost.org/trac/boost/changeset/67798
>
>
> What if I don't care that much about compile times and I don't want
> unnecessary runtime overhead?
This is in the code path that's executed when
1) The source type doesn't have a nothrow copy constructor,
2) The source type doesn't have a nothrow move constructor, and
3) None of the variant types has a nothrow default constructor.
The cost is already 2 switch statements (more if there are
a large number of types), 1 new/delete pair, 1 call to the
copy constructor of the type that the variant already holds,
2 calls to its destructor, and 1 call to the copy constructor
of the new type.
a) If the small extra overhead actually matters to you, you
should probably be avoiding this branch to begin with.
b) There's no guarantee that it actually makes the code
slower, since it significantly reduces the code size.
(The O(n^2) is function templates that are doing real
work.)
In Christ,
Steven Watanabe
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