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
This commit is contained in:
Paul Sokolovsky 2016-05-10 00:56:51 +03:00
parent 40f0096ee7
commit 6f34e138f1
1 changed files with 1 additions and 1 deletions

View File

@ -151,7 +151,7 @@ STATIC bool vstr_ensure_extra(vstr_t *vstr, size_t size) {
if (vstr->fixed_buf) { if (vstr->fixed_buf) {
return false; 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); char *new_buf = m_renew(char, vstr->buf, vstr->alloc, new_alloc);
if (new_buf == NULL) { if (new_buf == NULL) {
vstr->had_error = true; vstr->had_error = true;