empty function optimizations
Joe Buck
jbuck@racerx.synopsys.com
Wed Jul 12 17:17:00 GMT 2000
> > I thought that any function calling operator++ on an iterator would need to
> > know sizeof(T)?
>
> Well, list::operator++ specifically does not need to know the size of
> the list elements; it is a linked list.
You mean list::iterator::operator++, I presume.
But this is another case of a very small inlined function.
The list iterator is effectively a pointer; if it is in a register,
operator++ will expand into one RISC or x86 instruction; the key code
is just
_M_node = _M_node->_M_next;
Please don't waste mental cycles thinking about how to optimize such
things! (other than the usual Stepanov extraction penalty overhead,
but we do pretty well now for structs/classes that have one object that
fits in a register).
More information about the Gcc
mailing list