Improve memory backend of mio_read()
Drop the loop in mem_read() in favor of a single memcpy() call. This greatly improves performances when nmemb > 1, for a small loss for some values of size when nmemb == 1. Gain can theoretically be infinite since swapping nmemb and size parameters changes almost nothing while it had a dramatic performance impact previously. Loss is up to about 25% in the worst case for some values of size when nmemb is 1. Also, now the function always copies as much data as possible, not only whole blocks. This follows the glibc implementation of fread() and simplifies the code. Doing so also fixes the position after a partial read to be at the last readable character rather than the end of the last read block.
Showing
Please
register
or
sign in
to comment