[RFA] Algorithms vs operator* and operator==

Paolo Carlini pcarlini@suse.de
Mon Nov 15 12:32:00 GMT 2004


chris wrote:

> This seems to be the line we have trouble with, as it could lead to an 
> expensive copy. I haven't fully tested it yet, but I wonder if this 
> line would be better expressed as:
> typeof(*__first) __value = *__first; (where I've only just found typeof).

Nice idea! But...

> I've done some benchmarks, and I'm reasonably convinced that this is 
> both safe and the most efficent way of doing things. If *__first is a 
> reference, we just store the reference and access it twice. If 
> *__first is returned by value, then we only get it by value once and 
> use it twice. Does this seem safe / sensible?

... while seems safe and sensible to me, I'm not sure that we really 
want to add this kind of complexity to the code (also involving an 
extension): how much slow at computing operator* and operator== can we 
expect an input_iterator to be? In fact, our internal worst case, 
istreambuf_iterator, is now doing much better than before and some tests 
of mine show that probably there isn't much left to gain... Can you also 
benchmark a little more with current mainline?

Other opinions?

Thanks!
Paolo.



More information about the Libstdc++ mailing list