Skip to content

Conversation

scpeters
Copy link
Member

@scpeters scpeters commented Sep 9, 2024

🦟 Bug fix

Part of #1478

Summary

The performance of Element::Clone is poor, as noted in #1478. This is a small change to attempt to improve memory allocation.

There are several for-loops in Element::Clone that call std::vector::push_back, and since the vector size is known in advance, use std::vector::reserve to avoid multiple vector resizes.

I ran the unit tests with this change, and I didn't observe any noticeable speed-up.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

There are several for-loops in Element::Clone that call
std::vector::push_back, and since the vector size is
known in advance, use std::vector::reserve to avoid
multiple vector resizes.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@azeey
Copy link
Collaborator

azeey commented Aug 1, 2025

@scpeters not sure if we'll have time to tackle #1478. This PR looks fine as is, but it's a draft, so I wasn't if you wanted to do more. Let me know if you want to keep it in the "Jetty Release" milestone.

@scpeters
Copy link
Member Author

scpeters commented Aug 2, 2025

@scpeters not sure if we'll have time to tackle #1478. This PR looks fine as is, but it's a draft, so I wasn't if you wanted to do more. Let me know if you want to keep it in the "Jetty Release" milestone.

we can remove this from the jetty release milestone

@azeey azeey removed this from the Jetty Release milestone Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏛️ ionic Gazebo Ionic

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants