From: Vsevolod Stakhov Date: Thu, 23 Jun 2022 20:57:19 +0000 (+0100) Subject: [Minor] Grow small strings more quickly X-Git-Tag: 3.3~178 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aec9ff27cb3eee126594904282610d619ff57416;p=thirdparty%2Frspamd.git [Minor] Grow small strings more quickly --- diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c index 3f3af5357c..3698bdb3fc 100644 --- a/src/libutil/fstring.c +++ b/src/libutil/fstring.c @@ -125,7 +125,12 @@ rspamd_fstring_suggest_size (gsize len, gsize allocated, gsize needed_len) { gsize newlen, optlen = 0; - newlen = MAX (len + needed_len, 1 + allocated * 3 / 2); + if (allocated < 4096) { + newlen = MAX (len + needed_len, allocated * 2); + } + else { + newlen = MAX (len + needed_len, 1 + allocated * 3 / 2); + } #ifdef HAVE_MALLOC_SIZE optlen = sys_alloc_size (newlen + sizeof (rspamd_fstring_t));