Skip to content

Commit

Permalink
Removed unnecessary int cast to avoid Integer allocations (#1927)
Browse files Browse the repository at this point in the history
This pull request attempts to reduce Integer allocations when using an animation that has a ValueCallback to change some colors.

Resolves #1926
  • Loading branch information
pablorengo authored Oct 19, 2021
1 parent ca98cf2 commit 8ae55a9
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ public int getIntValue(Keyframe<Integer> keyframe, float keyframeProgress) {
if (keyframe.startValue == null || keyframe.endValue == null) {
throw new IllegalStateException("Missing values for keyframe.");
}
int startColor = keyframe.startValue;
int endColor = keyframe.endValue;

if (valueCallback != null) {
//noinspection ConstantConditions
Integer value = valueCallback.getValueInternal(keyframe.startFrame, keyframe.endFrame, startColor,
endColor, keyframeProgress, getLinearCurrentKeyframeProgress(), getProgress());
Integer value = valueCallback.getValueInternal(keyframe.startFrame, keyframe.endFrame, keyframe.startValue,
keyframe.endValue, keyframeProgress, getLinearCurrentKeyframeProgress(), getProgress());
if (value != null) {
return value;
}
}

return GammaEvaluator.evaluate(MiscUtils.clamp(keyframeProgress, 0f, 1f), startColor, endColor);
return GammaEvaluator.evaluate(MiscUtils.clamp(keyframeProgress, 0f, 1f), keyframe.startValue, keyframe.endValue);
}

/**
Expand Down

0 comments on commit 8ae55a9

Please sign in to comment.