This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: empty function optimizations



> > 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).




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]