|
Boost : |
Subject: Re: [boost] Stack-based vector container
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2011-01-23 18:59:47
On Sun, Jan 23, 2011 at 1:01 PM, Thorsten Ottosen <nesotto_at_[hidden]> wrote:
> As for the conjectured extra indirection, then I'm not sure it can become
> any major performance problem, nor do I see how one can avoid it when we
> need to go for the heap in certain cases.
Clearly the extra indirection is the only potential problem, otherwise
a stack-based vector implementation could probably be replaced by a
stack-based std::vector allocator.
However, the cost of the extra indirection is platform-dependent and
difficult to measure in the abstract. In my experience, most cases
when someone has complained about inefficiencies in std::vector boil
down to incorrect use:
- not using reserve();
- calling push_back()/insert() in a loop (which is inefficient even
with reserve);
- iterating by redundantly calling end() each time;
- using operator[] for sequential access to the elements.
So the only meaningful way to evaluate the benefits of a std::vector
alternative is to discuss specific use cases, considering other
alternatives as well.
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk