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
This commit is contained in:
Hermet Park 2020-04-19 11:13:28 +09:00
parent b2de30ba48
commit 75f2bc5f38

View file

@ -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<SwSpan*>(realloc(rle->spans, newSize * sizeof(SwSpan)));
rle->spans = static_cast<SwSpan*>(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