From c4aea880440b603199fa53bdd9b13b9675d27d5d Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Thu, 26 Jul 2018 12:46:07 +0900 Subject: [PATCH] lottie/optimization: added reserve() on lottieshapeData to optimize memory allocation Change-Id: Ic41d90a4463b54c47d3f39fa72bb09d5ddbc47f0 --- src/lottie/lottiemodel.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lottie/lottiemodel.h b/src/lottie/lottiemodel.h index 9e37dc1..93bcf4b 100644 --- a/src/lottie/lottiemodel.h +++ b/src/lottie/lottiemodel.h @@ -103,6 +103,9 @@ inline const LottieColor operator*(float m, const LottieColor &c) class LottieShapeData { public: + void reserve(int size) { + mPoints.reserve(mPoints.size() + size); + } VPath toPath() const{ if (mPoints.empty()) return VPath(); @@ -221,6 +224,7 @@ public: return LottieShapeData(); LottieShapeData result; + result.reserve(mStartValue.mPoints.size()); for (unsigned int i = 0 ; i < mStartValue.mPoints.size(); i++) { result.mPoints.push_back(mStartValue.mPoints[i] + progress * (mEndValue.mPoints[i] - mStartValue.mPoints[i])); } -- 2.7.4