But this isn’t how Io.Reader
/Io.Writer
work, instead there we have a pointer to a concrete Reader/Writer instance and a few fields which are used in the hot path and once their buffer is full they use their constant pointer to a constant vtable to deal with that full buffer and after that they again work on concrete direct data. Devirtualization is much less of a concern because most of the operations aren’t virtual to begin with.
Here is an attempt at visualizing what is going on with *Io.Writer
:
The drain buffer only happens if the buffer is too full to fit the data that is about to be written.