lottie/vector: reserve memory only when required. 74/185374/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Mon, 30 Jul 2018 05:34:24 +0000 (14:34 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Mon, 30 Jul 2018 05:34:24 +0000 (14:34 +0900)
Change-Id: Ia86c292d66c1060d33ccffd2fe5922480d219eb4

src/vector/vrle.cpp

index 87365f5..7fd4004 100644 (file)
@@ -303,7 +303,8 @@ inline static void copyArrayToVector(const VRle::Span *span, int count,
                                      std::vector<VRle::Span> &v)
 {
     // make sure enough memory available
-    v.reserve(v.size() + count);
+    if (v.capacity() < v.size() + count)
+        v.reserve(v.size() + count);
     std::copy(span, span + count, back_inserter(v));
 }