py/objstringio: Slightly optimize stringio_copy_on_write for code size.

With the memcpy() call placed last it avoids the effects of registers
clobbering.  It's definitely effective in non-inlined functions, but even
here it is still making a small difference.  For example, on stm32, this
saves an extra `ldr` instruction to load `o->vstr` after the memcpy()
returns.
pull/1/head
Yonatan Goldschmidt 2019-11-25 17:21:54 +02:00 committed by Damien George
parent 1675b98e74
commit 4318a6d755
1 changed files with 1 additions and 1 deletions

View File

@ -70,9 +70,9 @@ STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *er
STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) {
const void *buf = o->vstr->buf;
o->vstr->buf = m_new(char, o->vstr->len);
memcpy(o->vstr->buf, buf, o->vstr->len);
o->vstr->fixed_buf = false;
o->ref_obj = MP_OBJ_NULL;
memcpy(o->vstr->buf, buf, o->vstr->len);
}
STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {