From de15165774db6a0964635ab9186943cab8cad42d Mon Sep 17 00:00:00 2001 From: Daniel McArdle Date: Thu, 13 May 2021 23:08:31 -0400 Subject: [PATCH] [psaux] Use doubling allocation strategy for CF2_ArrStack. Fixes timeout reported as https://crbug.com/1206181 * src/psaux/psarrst.c (cf2_arrstack_{push,init}): Implement it. * src/psaux/psarrst.h (CF2_ArrStackiRec): Drop `chunk'. --- ChangeLog | 11 +++++++++++ src/psaux/psarrst.c | 5 ++--- src/psaux/psarrst.h | 1 - 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f490d0a98..2fdcce51f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2021-05-13 Daniel McArdle + + [psaux] Use doubling allocation strategy for CF2_ArrStack. + + Fixes timeout reported as + + https://crbug.com/1206181 + + * src/psaux/psarrst.c (cf2_arrstack_{push,init}): Implement it. + * src/psaux/psarrst.h (CF2_ArrStackiRec): Drop `chunk'. + 2021-05-12 Alexei Podtelezhnikov * src/smooth/ftgrays.c (FT_MAX_GRAY_SPANS): Increase from 10 to 16. diff --git a/src/psaux/psarrst.c b/src/psaux/psarrst.c index 7f27c2484..70313d283 100644 --- a/src/psaux/psarrst.c +++ b/src/psaux/psarrst.c @@ -65,7 +65,6 @@ arrstack->error = error; arrstack->sizeItem = sizeItem; arrstack->allocated = 0; - arrstack->chunk = 10; /* chunks of 10 items */ arrstack->count = 0; arrstack->totalSize = 0; arrstack->ptr = NULL; @@ -216,9 +215,9 @@ if ( arrstack->count == arrstack->allocated ) { - /* grow the buffer by one chunk */ + /* increase the buffer size */ if ( !cf2_arrstack_setNumElements( - arrstack, arrstack->allocated + arrstack->chunk ) ) + arrstack, arrstack->allocated * 2 + 16 ) ) { /* on error, ignore the push */ return; diff --git a/src/psaux/psarrst.h b/src/psaux/psarrst.h index 098617b25..31e5330cc 100644 --- a/src/psaux/psarrst.h +++ b/src/psaux/psarrst.h @@ -55,7 +55,6 @@ FT_BEGIN_HEADER size_t sizeItem; /* bytes per element */ size_t allocated; /* items allocated */ - size_t chunk; /* allocation increment in items */ size_t count; /* number of elements allocated */ size_t totalSize; /* total bytes allocated */