Skip to content

Commit

Permalink
Avoid repeated value read in SubtractionAnimatedNode
Browse files Browse the repository at this point in the history
Summary:
Minor optimization, but spotted this while reviewing the implementation for D33622997

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33622996

fbshipit-source-id: 8712753803fc46e6a046d50f77454a813e4a641a
  • Loading branch information
javache authored and facebook-github-bot committed Jan 18, 2022
1 parent b210571 commit 08e7677
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void update() {
mValue += ((ValueAnimatedNode) animatedNode).getValue();
} else {
throw new JSApplicationCausedNativeException(
"Illegal node ID set as an input for " + "Animated.Add node");
"Illegal node ID set as an input for Animated.Add node");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private double getInputNodeValue() {
AnimatedNode animatedNode = mNativeAnimatedNodesManager.getNodeById(mInputNodeTag);
if (animatedNode == null || !(animatedNode instanceof ValueAnimatedNode)) {
throw new JSApplicationCausedNativeException(
"Illegal node ID set as an input for " + "Animated.DiffClamp node");
"Illegal node ID set as an input for Animated.DiffClamp node");
}

return ((ValueAnimatedNode) animatedNode).getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public ModulusAnimatedNode(
public void update() {
AnimatedNode animatedNode = mNativeAnimatedNodesManager.getNodeById(mInputNode);
if (animatedNode != null && animatedNode instanceof ValueAnimatedNode) {
final double value = ((ValueAnimatedNode) animatedNode).getValue();
double value = ((ValueAnimatedNode) animatedNode).getValue();
mValue = (value % mModulus + mModulus) % mModulus;
} else {
throw new JSApplicationCausedNativeException(
"Illegal node ID set as an input for " + "Animated.modulus node");
"Illegal node ID set as an input for Animated.modulus node");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void update() {
mValue *= ((ValueAnimatedNode) animatedNode).getValue();
} else {
throw new JSApplicationCausedNativeException(
"Illegal node ID set as an input for " + "Animated.multiply node");
"Illegal node ID set as an input for Animated.multiply node");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public void update() {
double value = ((ValueAnimatedNode) animatedNode).getValue();
if (i == 0) {
mValue = value;
continue;
} else {
mValue -= value;
}
mValue -= ((ValueAnimatedNode) animatedNode).getValue();
} else {
throw new JSApplicationCausedNativeException(
"Illegal node ID set as an input for " + "Animated.subtract node");
"Illegal node ID set as an input for Animated.subtract node");
}
}
}
Expand Down

0 comments on commit 08e7677

Please sign in to comment.