fix: Improve performance#7
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the
AnimatedComponentWriterand its usage to improve performance and safety by making the internalPropertyWriterreusable. The main changes involve makingPropertyWriterstateless between uses, introducing areset()method, and updating usage patterns in bothAnimatedComponentWriterandComponentRegistry.Refactoring for Reusability and Efficiency:
PropertyWriterreusable by removing reliance on cereal's internal state, replacing constructor parameters with areset()method to set state before each use. This avoids issues with ID collisions and invalid references when reusing the archive. (include/nodec_animation/animated_component_writer.hpp, include/nodec_animation/animated_component_writer.hppR26-R67)PropertyWritermember variables:source_is now a pointer (nullable), andtime_is no longerconst, to support resetting. (include/nodec_animation/animated_component_writer.hpp, include/nodec_animation/animated_component_writer.hppL84-R119)AnimatedComponentWriterto hold a single reusable instance ofPropertyWriteras a member, initializing it in the constructor and callingreset()before each write operation. (include/nodec_animation/animated_component_writer.hpp, include/nodec_animation/animated_component_writer.hppL105-R137)Integration with Component Registry:
ComponentRegistryto use a persistent, mutableAnimatedComponentWritermember (writer_) instead of creating a new instance for each write, further reducing allocations and improving performance. (include/nodec_animation/component_registry.hpp, include/nodec_animation/component_registry.hppL38-R42)