mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
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:
parent
b2de30ba48
commit
75f2bc5f38
1 changed files with 2 additions and 2 deletions
|
@ -145,9 +145,9 @@ static void _genSpan(SwRleData* rle, SwSpan* spans, size_t count)
|
||||||
/* alloc is required to prevent free and reallocation */
|
/* alloc is required to prevent free and reallocation */
|
||||||
/* when the rle needs to be regenerated because of attribute change. */
|
/* when the rle needs to be regenerated because of attribute change. */
|
||||||
if (rle->alloc < newSize) {
|
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);
|
assert(rle->spans);
|
||||||
rle->alloc = newSize;
|
rle->alloc = rle->size + (count << 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//copy the new spans to the allocated memory
|
//copy the new spans to the allocated memory
|
||||||
|
|
Loading…
Add table
Reference in a new issue