Lars Gullik Bjønnes wrote: > | Sorry to drop a spanner in your well-oiled machine, but I really > | must point out that boost::function introduces an indirection > | equivalent to a virtual function call. Thus a change like this > | which affects the inner loop is likely to introduce a significant > | performance hit. The struct solution will be optimized away > | entirely. > > Why do you think I am replacing all the nice bind stuff with > FormatNamesEqual and the like in the patches I actually commit :-) > > yes, belive it or not, this is the exact reason.
Hmmmm. I don't know what I'm talking about in detail, but boost::bind is not the same as boost::function. Specifically, I believe that there is no performance hit at all in using boost::bind. My evidence comes, paradoxically, from the boost::lambda docs (See section 7.1 Performance. http://www.boost.org/libs/lambda/doc/ar01s07.html#id2807572). boost::lambda has a bind mechanism that has a different implementation to boost::bind. Nonetheless, it's reasonable to expect the two to be similarly efficient. These same docs (8.1. Boost Function http://www.boost.org/libs/lambda/doc/ar01s08.html#id2808518) also mention that there is a performance hit in using boost::function. So. Conclusions. You don't need to get rid of the bind stuff on performance grounds. Be wary of boost::function in inner loops however. Hope this info helps. -- Angus