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

Fix std::vector refactor mistake #6836

Merged
merged 3 commits into from
Aug 31, 2023
Merged

Conversation

messmerd
Copy link
Member

@messmerd messmerd commented Aug 30, 2023

When usages of QVector were replaced with std::vector in the Core in #6477, some methods that now return const std::vector& were left unchanged at the call sites. In many cases, the const reference returned by these methods was stored by value instead of by const reference. Because the QVector objects are implicitly shared and have copy-on-write behavior, this previously didn't really matter and was a constant time operation when the objects were only read from - as was the case most of the time. But now with std::vector, all of these std::vector objects are being deep copied which is O(n) and is not real-time safe.

This PR fixes that oversight by using references at the call sites.

@sakertooth
Copy link
Contributor

Were you able to verify that these were all the applicable call sites?

@messmerd
Copy link
Member Author

Were you able to verify that these were all the applicable call sites?

I'm pretty sure I covered everything. I searched for every std::vector, type alias for a std::vector, every method returning or accepting a std::vector of some form, and every usage of those methods in include/ and src/.

Copy link
Contributor

@sakertooth sakertooth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a question.

src/gui/editors/PianoRoll.cpp Show resolved Hide resolved
@sakertooth sakertooth merged commit 8a94fb3 into LMMS:master Aug 31, 2023
9 checks passed
@messmerd messmerd deleted the vector-fix branch August 31, 2023 17:42
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

Successfully merging this pull request may close these issues.

3 participants