Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid excessive copies of optionals #94

Open
Flamefire opened this issue Jul 25, 2020 · 2 comments
Open

Avoid excessive copies of optionals #94

Flamefire opened this issue Jul 25, 2020 · 2 comments

Comments

@Flamefire
Copy link
Collaborator

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.

@mat007
Copy link
Owner

mat007 commented Aug 3, 2020

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

@Flamefire
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants