From 5ba0ecfb2b65fe84f1ff102863161e14aa5a5708 Mon Sep 17 00:00:00 2001 From: Daniel Jour Date: Tue, 19 Nov 2019 21:41:08 +0100 Subject: [PATCH] Keyframe::GetInt() and Keyframe::GetLong() use GetValue GetInt(), GetLong() are exactly the same as GetValue() except that their result is rounded and converted to the repsective data type. Thus avoid code duplication and use GetValue(). --- src/KeyFrame.cpp | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/KeyFrame.cpp b/src/KeyFrame.cpp index aa544c9c..100c108d 100644 --- a/src/KeyFrame.cpp +++ b/src/KeyFrame.cpp @@ -251,45 +251,13 @@ double Keyframe::GetValue(int64_t index) // Get the rounded INT value at a specific index int Keyframe::GetInt(int64_t index) { - // Check if it needs to be processed - if (needs_update) - Process(); - - // Is index a valid point? - if (index >= 0 && index < Values.size()) - // Return value - return int(round(Values[index].Y)); - else if (index < 0 && Values.size() > 0) - // Return the minimum value - return int(round(Values[0].Y)); - else if (index >= Values.size() && Values.size() > 0) - // return the maximum value - return int(round(Values[Values.size() - 1].Y)); - else - // return a blank coordinate (0,0) - return 0; + return int(round(GetValue(index))); } // Get the rounded INT value at a specific index int64_t Keyframe::GetLong(int64_t index) { - // Check if it needs to be processed - if (needs_update) - Process(); - - // Is index a valid point? - if (index >= 0 && index < Values.size()) - // Return value - return long(round(Values[index].Y)); - else if (index < 0 && Values.size() > 0) - // Return the minimum value - return long(round(Values[0].Y)); - else if (index >= Values.size() && Values.size() > 0) - // return the maximum value - return long(round(Values[Values.size() - 1].Y)); - else - // return a blank coordinate (0,0) - return 0; + return long(round(GetValue(index))); } // Get the direction of the curve at a specific index (increasing or decreasing)