lottie/optimization: added reserve() on lottieshapeData to optimize memory allocation 82/185082/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Thu, 26 Jul 2018 03:46:07 +0000 (12:46 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Thu, 26 Jul 2018 03:46:07 +0000 (12:46 +0900)
Change-Id: Ic41d90a4463b54c47d3f39fa72bb09d5ddbc47f0

src/lottie/lottiemodel.h

index 9e37dc1..93bcf4b 100644 (file)
@@ -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]));
          }