aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-06-23 21:57:19 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-06-23 21:57:19 +0100
commitaec9ff27cb3eee126594904282610d619ff57416 (patch)
tree8eb03f36c9b4efcc6c48f9638de31caf3d4612ff /src/libutil
parent1eaf3b243d208af51327e8f3a5940279c93e4d9a (diff)
downloadrspamd-aec9ff27cb3eee126594904282610d619ff57416.tar.gz
rspamd-aec9ff27cb3eee126594904282610d619ff57416.zip
[Minor] Grow small strings more quickly
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/fstring.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c
index 3f3af5357..3698bdb3f 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));