From 75f2bc5f38c8d6a62ae55b2d9a24ed1de3c6f292 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Sun, 19 Apr 2020 11:13:28 +0900 Subject: [PATCH] sw_engine: optimization++ Adjust rle span generation size to reduce memory allocation. This span growing is experimentally increased, undeterministic. Thus We need too increase them every requests, if we increase their size x 4, we can avoid a lot of memory copy in advance. Change-Id: Idd24024204a69fa3b6857728b95aa63a3ac26c5e --- src/lib/sw_engine/tvgSwRle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/sw_engine/tvgSwRle.cpp b/src/lib/sw_engine/tvgSwRle.cpp index 25b9c03..1d3d498 100644 --- a/src/lib/sw_engine/tvgSwRle.cpp +++ b/src/lib/sw_engine/tvgSwRle.cpp @@ -145,9 +145,9 @@ static void _genSpan(SwRleData* rle, SwSpan* spans, size_t count) /* alloc is required to prevent free and reallocation */ /* when the rle needs to be regenerated because of attribute change. */ if (rle->alloc < newSize) { - rle->spans = static_cast(realloc(rle->spans, newSize * sizeof(SwSpan))); + rle->spans = static_cast(realloc(rle->spans, (count + rle->size) << 2 * sizeof(SwSpan))); assert(rle->spans); - rle->alloc = newSize; + rle->alloc = rle->size + (count << 2); } //copy the new spans to the allocated memory -- 2.7.4