pass config in C++ Animated with std::move (#52039)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52039

changelog: [internal]

config can be passed with std::move to avoid copy.

Reviewed By: rshest, javache

Differential Revision: D76628921

fbshipit-source-id: 82a90ce604d2a82a388eb4fa63f22deda6ec92ed
This commit is contained in:
Samuel Susla authored and Facebook GitHub Bot committed 2025-06-16 04:50:47 -07:00
1 parent d20b9cfdf0
commit ffe928ce50
9 files changed
+19 -16

No files matched your search

@@ -241,7 +241,10 @@ void AnimatedModule::executeOperation(const Operation& operation) {
nodesManager_->disconnectAnimatedNodes(op.parentTag, op.childTag);
} else if constexpr (std::is_same_v<T, StartAnimatingNodeOp>) {
nodesManager_->startAnimatingNode(
op.animationId, op.nodeTag, op.config, std::move(op.endCallback));
op.animationId,
op.nodeTag,
std::move(op.config),
std::move(op.endCallback));
} else if constexpr (std::is_same_v<T, StopAnimationOp>) {
nodesManager_->stopAnimation(op.animationId, false);
} else if constexpr (std::is_same_v<T, SetAnimatedNodeValueOp>) {
@@ -273,7 +273,7 @@ void NativeAnimatedNodesManager::stopAnimationsForNode(Tag nodeTag) {
void NativeAnimatedNodesManager::startAnimatingNode(
int animationId,
Tag animatedNodeTag,
const folly::dynamic& config,
folly::dynamic config,
std::optional<AnimationEndCallback> endCallback) noexcept {
if (auto iter = activeAnimations_.find(animationId);
iter != activeAnimations_.end()) {
@@ -291,7 +291,7 @@ void NativeAnimatedNodesManager::startAnimatingNode(
animationId,
animatedNodeTag,
std::move(endCallback),
config,
std::move(config),
this);
} break;
case AnimationDriverType::Spring: {
@@ -299,7 +299,7 @@ void NativeAnimatedNodesManager::startAnimatingNode(
animationId,
animatedNodeTag,
std::move(endCallback),
config,
std::move(config),
this);
} break;
case AnimationDriverType::Decay: {
@@ -307,7 +307,7 @@ void NativeAnimatedNodesManager::startAnimatingNode(
animationId,
animatedNodeTag,
std::move(endCallback),
config,
std::move(config),
this);
} break;
}
@@ -103,7 +103,7 @@ class NativeAnimatedNodesManager {
void startAnimatingNode(
int animationId,
Tag animatedNodeTag,
const folly::dynamic& config,
folly::dynamic config,
std::optional<AnimationEndCallback> endCallback) noexcept;
void stopAnimation(
@@ -18,15 +18,15 @@ DecayAnimationDriver::DecayAnimationDriver(
int id,
Tag animatedValueTag,
std::optional<AnimationEndCallback> endCallback,
const folly::dynamic& config,
folly::dynamic config,
NativeAnimatedNodesManager* manager)
: AnimationDriver(
id,
animatedValueTag,
std::move(endCallback),
config,
std::move(config),
manager),
velocity_(config["velocity"].asDouble()),
velocity_(config_["velocity"].asDouble()),
deceleration_(config_["deceleration"].asDouble()) {
react_native_assert(deceleration_ > 0);
}
@@ -21,7 +21,7 @@ class DecayAnimationDriver : public AnimationDriver {
int id,
Tag animatedValueTag,
std::optional<AnimationEndCallback> endCallback,
const folly::dynamic& config,
folly::dynamic config,
NativeAnimatedNodesManager* manager);
protected:
@@ -24,13 +24,13 @@ FrameAnimationDriver::FrameAnimationDriver(
int id,
Tag animatedValueTag,
std::optional<AnimationEndCallback> endCallback,
const folly::dynamic& config,
folly::dynamic config,
NativeAnimatedNodesManager* manager)
: AnimationDriver(
id,
animatedValueTag,
std::move(endCallback),
config,
std::move(config),
manager) {
onConfigChanged();
}
@@ -21,7 +21,7 @@ class FrameAnimationDriver : public AnimationDriver {
int id,
Tag animatedValueTag,
std::optional<AnimationEndCallback> endCallback,
const folly::dynamic& config,
folly::dynamic config,
NativeAnimatedNodesManager* manager);
protected:
@@ -21,13 +21,13 @@ SpringAnimationDriver::SpringAnimationDriver(
int id,
Tag animatedValueTag,
std::optional<AnimationEndCallback> endCallback,
const folly::dynamic& config,
folly::dynamic config,
NativeAnimatedNodesManager* manager)
: AnimationDriver(
id,
animatedValueTag,
std::move(endCallback),
config,
std::move(config),
manager),
springStiffness_(config_["stiffness"].asDouble()),
springDamping_(config_["damping"].asDouble()),
@@ -21,7 +21,7 @@ class SpringAnimationDriver : public AnimationDriver {
int id,
Tag animatedValueTag,
std::optional<AnimationEndCallback> endCallback,
const folly::dynamic& config,
folly::dynamic config,
NativeAnimatedNodesManager* manager);
protected: