Subject: Re: [boost] [utility] new auto_buffer class --- RFC
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-03-02 10:55:07
-----BEGIN PGP SIGNED MESSAGE-----
On Monday 02 March 2009, Frank Mori Hess wrote:
> On Monday 02 March 2009, Thorsten Ottosen wrote:
> > you might not expect 95% of all lines to be less than 512 chars. Thus
> > you can use
> > boost::auto_buffer<char,512> buffer;
> > to avoid heap-allocations in 95% of the cases. This can be a major
> > speed-improvement. For the remaining 5% of the cases, the buffer will be
> > placed on the heap, but the code from the user's persective remains the
> > same.
> From glancing at the implementation posted to the list, it does not appear
> to fall back to heap allocation once the maximum stack capacity is reached.
> push_back() simply asserts that the stack capacity hasn't been used up yet.
> Although, I would be able to use such a container if it were added as a
> utility to boost, as I implemented one for my own use as an internal
> optimization in Boost.Signals2 (boost/signals2/detail/stack_vector.hpp and
Ah, looking at little further at the code I see when you say fall-back on the
heap, you only mean you can pass a capacity to the constructor that exceeds
the stack storage, but the auto_buffer can never be resized after that.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk