Skip to content

fix: Improve performance#7

Merged
ContentsViewer merged 3 commits into
mainfrom
feature/update
Jan 3, 2026
Merged

fix: Improve performance#7
ContentsViewer merged 3 commits into
mainfrom
feature/update

Conversation

@ContentsViewer
Copy link
Copy Markdown
Member

This pull request refactors the AnimatedComponentWriter and its usage to improve performance and safety by making the internal PropertyWriter reusable. The main changes involve making PropertyWriter stateless between uses, introducing a reset() method, and updating usage patterns in both AnimatedComponentWriter and ComponentRegistry.

Refactoring for Reusability and Efficiency:

  • Made PropertyWriter reusable by removing reliance on cereal's internal state, replacing constructor parameters with a reset() 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)
  • Changed PropertyWriter member variables: source_ is now a pointer (nullable), and time_ is no longer const, to support resetting. (include/nodec_animation/animated_component_writer.hpp, include/nodec_animation/animated_component_writer.hppL84-R119)
  • Updated AnimatedComponentWriter to hold a single reusable instance of PropertyWriter as a member, initializing it in the constructor and calling reset() before each write operation. (include/nodec_animation/animated_component_writer.hpp, include/nodec_animation/animated_component_writer.hppL105-R137)

Integration with Component Registry:

  • Updated ComponentRegistry to use a persistent, mutable AnimatedComponentWriter member (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)

@ContentsViewer ContentsViewer merged commit a7cc3ea into main Jan 3, 2026
1 check passed
@ContentsViewer ContentsViewer deleted the feature/update branch January 3, 2026 03:15
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.

1 participant