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

Pass arguments by const reference to avoid making copies #585

Merged
merged 2 commits into from
Apr 19, 2024

Conversation

jmcarcell
Copy link
Member

BEGINRELEASENOTES

  • Pass arguments by const reference to avoid making copies in a few places where passing by value was used

ENDRELEASENOTES

I think copies are not needed in these places

@@ -206,7 +206,7 @@ podio::CollectionReadBuffers createBuffersV{{ schemaVersion }}(bool isSubset) {
{% endfor %}
}

readBuffers.createCollection = [](podio::CollectionReadBuffers buffers, bool isSubsetColl) {
readBuffers.createCollection = [](const podio::CollectionReadBuffers& buffers, bool isSubsetColl) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not particularly liking this because it's a bit misleading, because something down the line will be stealing the data from these buffers:

m_refCollections(std::move(*buffers.references)),
m_vecmem_info(std::move(*buffers.vectorMembers)) {

On the other hand this is the case already now because the copy we make at the moment will also have the same behavior. In the end all of this should be cleaned up better at some point (see #506).

Interestingly this also seems to work even though we technically assign to a different std::function:

using CreateFuncT = std::function<std::unique_ptr<podio::CollectionBase>(podio::CollectionReadBuffers, bool)>;

@tmadlener tmadlener merged commit 6d483dc into AIDASoft:master Apr 19, 2024
16 of 18 checks passed
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.

2 participants