Answer the question
In order to leave comments, you need to log in
How to get rid of redundant operations in BufferedStream?
Why does the system BufferedStream frequently refer to the stream it buffers when it shouldn't? For example, if I first read the first few bytes and then perform a Seek operation, the Buffered Stream will redirect it to the underlying stream, although in principle I can only read data that is already buffered by it with the next request, or if more data is needed than is already in buffer, BufferedStream will still be forced to move the cursor by the size of the buffer data, so the first position change is redundant in any case.
In general, as I understand it, the standard implementation is very primitive and tailored for a simple scenario of one pass through a large file, maybe there are more advanced implementations that would proceed from the fact that all operations with the source stream are very expensive and should be performed only when necessary?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question