From d9d9d7b278c9efbcf138bc45dccf06a216a1b69a Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Tue, 23 Mar 2021 19:13:05 +0900 Subject: Reduce memory reallocation due to Strgrow --- Str.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Str.c') diff --git a/Str.c b/Str.c index 9977c2d..f6b7670 100644 --- a/Str.c +++ b/Str.c @@ -282,7 +282,11 @@ void Strgrow(Str x) { int newlen, addlen; - addlen = x->area_size / 5; + + if (x->area_size < 8192) + addlen = x->area_size; + else + addlen = x->area_size / 2; if (addlen < INITIAL_STR_SIZE) addlen = INITIAL_STR_SIZE; newlen = x->area_size + addlen; -- cgit v1.2.3