Closed vishwa2710 closed 4 weeks ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 81.94%. Comparing base (
a255d17
) to head (8fa47ba
). Report is 1 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The changes involve significant modifications to the Environment
class in both the header and implementation files. The copy constructor and copy assignment operator have been removed, indicating a transition to a non-copyable design. The constructors have been updated to simplify object initialization by directly assigning passed parameters without cloning. This streamlining reduces complexity in managing Environment
instances and eliminates deep copy operations.
File | Change Summary |
---|---|
include/OpenSpaceToolkit/Physics/Environment.hpp | Removed copy constructor and copy assignment operator from Environment class. |
src/OpenSpaceToolkit/Physics/Environment.cpp | Updated constructor to simplify initialization; removed cloning logic; eliminated copy constructor and assignment operator. |
In the realm of space where objects play,
The copy's gone, we've found a new way.
With direct paths and simpler dreams,
TheEnvironment
flows like gentle streams.
No more clones, just a single embrace,
In the cosmic dance, we quicken our pace! 🌌✨
src/OpenSpaceToolkit/Physics/Environment.cpp (1)
``` Learnt from: vishwa2710 PR: open-space-collective/open-space-toolkit-physics#278 File: src/OpenSpaceToolkit/Physics/Environment.cpp:46-46 Timestamp: 2024-10-07T22:55:28.095Z Learning: In the `Environment` class, `aCentralCelestialObject` is a shared pointer to a `const Object`, ensuring immutability and preventing shared mutability concerns when assigning to `centralCelestialObject_`. ```
src/OpenSpaceToolkit/Physics/Environment.cpp (3)
`29-29`: **Direct Assignment Eliminates Unnecessary Cloning** Assigning `anObjectArray` directly to `objects_` without cloning improves performance and reduces memory overhead. Since `Object` instances are `Shared`, they are immutable, ensuring safe shared ownership. --- `46-46`: **Safe Direct Assignment of Central Celestial Object** Assigning `aCentralCelestialObject` directly to `centralCelestialObject_` is appropriate. As it is a `Shared `, immutability is ensured, and shared ownership does not introduce side effects. --- `50-53`: **Simplified Object Addition Enhances Readability** By adding `centralCelestialObject_` and the elements of `anObjectArray` directly to `objects_`, the code becomes cleaner and more efficient. Removing cloning operations reduces complexity and potential performance overhead.
Summary by CodeRabbit
New Features
Environment
objects by directly initializing with provided arrays and objects, improving performance.Bug Fixes
Refactor