From 6f34e138f1ecf197212dc1392cbffeea41b44a93 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 10 May 2016 00:56:51 +0300 Subject: [PATCH] py/vstr: Change allocation policy, +16 to requested size, instead of *2. Effect measured on esp8266 port: Before: >>> pystone_lowmem.main(10000) Pystone(1.2) time for 10000 passes = 44214 ms This machine benchmarks at 226 pystones/second >>> pystone_lowmem.main(10000) Pystone(1.2) time for 10000 passes = 44246 ms This machine benchmarks at 226 pystones/second After: >>> pystone_lowmem.main(10000) Pystone(1.2) time for 10000 passes = 44343ms This machine benchmarks at 225 pystones/second >>> pystone_lowmem.main(10000) Pystone(1.2) time for 10000 passes = 44376ms This machine benchmarks at 225 pystones/second --- py/vstr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/vstr.c b/py/vstr.c index f558e3fcb1..cf10f8471a 100644 --- a/py/vstr.c +++ b/py/vstr.c @@ -151,7 +151,7 @@ STATIC bool vstr_ensure_extra(vstr_t *vstr, size_t size) { if (vstr->fixed_buf) { return false; } - size_t new_alloc = ROUND_ALLOC((vstr->len + size) * 2); + size_t new_alloc = ROUND_ALLOC((vstr->len + size) + 16); char *new_buf = m_renew(char, vstr->buf, vstr->alloc, new_alloc); if (new_buf == NULL) { vstr->had_error = true;