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

Check if std::move needs to be used to move digits in some methods #131

Open
Tracked by #147
saxbophone opened this issue Feb 17, 2023 · 2 comments
Open
Tracked by #147
Labels
blocked This cannot be started until prerequisite(s) are completed good first issue Good for newcomers optimisation
Milestone

Comments

@saxbophone
Copy link
Owner

In some methods (friend operators), we create a temporary inside the function which is never used again before returning. We assign our digits from these members' digits. These variables can be moved, but I'm not sure if the compiler is smart enough to use move semantics here. We might need to use std::move() on each one to gain the benefits of move semantics in these places, and if it avoids a copy then it will likely increase performance.

I have marked the places where I think this can be done in the linked commit. Not sure I caught all of them, there may be others in the math support header...

@saxbophone saxbophone added the blocked This cannot be started until prerequisite(s) are completed label Feb 18, 2023
@saxbophone
Copy link
Owner Author

saxbophone commented Feb 18, 2023

This can't be done until #133 has been done, as the current data structure lacks a move assignment operator, but std::vector does have one.

@saxbophone saxbophone added this to the v0.6 milestone Feb 19, 2023
@saxbophone
Copy link
Owner Author

FWIW, there is no performance benefit in moving a digit individually, but there is a potential performance benefit in moving the digits container itself, as that prevents a copy. When I build sharray (which I intend to use instead of vector), I should definitely include a move constructor and move-assignment operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked This cannot be started until prerequisite(s) are completed good first issue Good for newcomers optimisation
Projects
None yet
Development

No branches or pull requests

1 participant