Commit 2c81b9be authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

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

parent 063e6e7d
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment