Skip to content

Commit 6f34e13

Browse files
committed
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
1 parent 40f0096 commit 6f34e13

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

py/vstr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ STATIC bool vstr_ensure_extra(vstr_t *vstr, size_t size) {
151151
if (vstr->fixed_buf) {
152152
return false;
153153
}
154-
size_t new_alloc = ROUND_ALLOC((vstr->len + size) * 2);
154+
size_t new_alloc = ROUND_ALLOC((vstr->len + size) + 16);
155155
char *new_buf = m_renew(char, vstr->buf, vstr->alloc, new_alloc);
156156
if (new_buf == NULL) {
157157
vstr->had_error = true;

0 commit comments

Comments
 (0)