py/modio: io.BufferedWriter: Describe flushing policy.

pull/1936/head
Paul Sokolovsky 2016-03-25 14:59:30 +02:00
rodzic 063e6e7d0a
commit 2c81b9be28
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -69,6 +69,12 @@ STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t si
return org_size;
}
// Buffer flushing policy here is to flush entire buffer all the time.
// This allows e.g. to have a block device as backing storage and write
// entire block to it. memcpy below is not ideal and could be optimized
// in some cases. But the way it is now it at least ensures that buffer
// is word-aligned, to guard against obscure cases when it matters, e.g.
// https://github.com/micropython/micropython/issues/1863
memcpy(self->buf + self->len, buf, rem);
buf = (byte*)buf + rem;
size -= rem;