commit aec9ff2: [Minor] Grow small strings more quickly
Vsevolod Stakhov
vsevolod at rspamd.com
Thu Jun 23 21:00:03 UTC 2022
Author: Vsevolod Stakhov
Date: 2022-06-23 21:57:19 +0100
URL: https://github.com/rspamd/rspamd/commit/aec9ff27cb3eee126594904282610d619ff57416 (HEAD -> master)
[Minor] Grow small strings more quickly
---
src/libutil/fstring.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
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));
More information about the Commits
mailing list