mat007 / turtle

C++ mock object library for Boost

Home Page:http://turtle.sourceforge.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Avoid excessive copies of optionals

Flamefire opened this issue · comments

During debugging I found that in a lot of the turtle code boost::optional instances are passed by value. This leads to a constructor and destructor call on each call making debugging a failure harder than it needs to be.

I'd suggest to accept those optionals by const& instead.

If I remember correctly optionals can’t be moved, right?
That probably makes sense to pass by reference anyway, yes.

I guess that depends on the Boost version but generally they should be able to be moved, but in the code they are not. In any case as this is a test library this is usually used in non-optimized builds where even moved optionals are costly: There are quite some functions to be called to determine how to move/copy an optional (check for empty etc) and those make debugging harder/longer