From 8ae55a9b0877036dbebdb75ebf122db377677487 Mon Sep 17 00:00:00 2001 From: Pablo Iacopi Date: Tue, 19 Oct 2021 19:38:36 -0300 Subject: [PATCH] Removed unnecessary int cast to avoid Integer allocations (#1927) This pull request attempts to reduce Integer allocations when using an animation that has a ValueCallback to change some colors. Resolves #1926 --- .../lottie/animation/keyframe/ColorKeyframeAnimation.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lottie/src/main/java/com/airbnb/lottie/animation/keyframe/ColorKeyframeAnimation.java b/lottie/src/main/java/com/airbnb/lottie/animation/keyframe/ColorKeyframeAnimation.java index 63030753ea..3c83b2684a 100644 --- a/lottie/src/main/java/com/airbnb/lottie/animation/keyframe/ColorKeyframeAnimation.java +++ b/lottie/src/main/java/com/airbnb/lottie/animation/keyframe/ColorKeyframeAnimation.java @@ -24,19 +24,17 @@ public int getIntValue(Keyframe 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); } /**