From: Hartmut Kaiser (hartmutkaiser_at_[hidden])
Date: 2004-01-09 07:44:13
Daniel Krügler (nee Spangenberg) wrote:
> Good morning, Hartmut!
> > during my current performance analysis sessions (to speed up Wave)
> > I've stumbled over the fact, that the current iterator_adaptor
> > implementation takes it's constructor parameter by value (the base
> > iterator). Is there any reason, why this isn't a const
> reference (the
> > base iterator parameter is then used to initialise the
> iterator_adaptor m_iterator member anyway)?
> > Changing it this way would speed up things a bit, especially if the
> > base iterator is not pointer based. Ok, I hear you say,
> please change
> > your iterator implementation, but not always I have full
> control over this ...
> One counter argument: I think, every algorithm of the
> standard library and even the std:reverse_iterator c'tor
> takes iterator arguments per value. The last example compares
> quite well to iterator_adaptor, doesn't it?
You're right, but IMHO this is a complete different situation. The iterator
adaptor constructor copies the iterator parameter anyway into the own
m_iterator member, so further working of the iterator_adaptor does not rely
on a reference as would do the algorithms, if they'd take references. Taking
the iterator parameter by const reference simply would avoid one additional
copy operation, which may be costly for more complex iterators.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk