Hi! New to rust programming and today I spent time on std::io::BufReader documentation.
I stopped on the following sentence :
BufReader<R>
can improve the speed of programs that make small and repeated read calls to the same file or network socket. It does not help when reading very large amounts at once, or reading just one or a few times. It also provides no advantage when reading from a source that is already in memory, like aVec<u8>
.
I understand how a buffered reader works with large and infrequent reads but I do not understand the following point:
It also provides no advantage when reading from a source that is already in memory, like a
Vec<u8>
.
What does it mean ? A BufReader is not supposed to read from file only ?
For example, if I have a custom file format to parse:
1
1
2
3
5
8
13
21
...
This kind of format will be loaded in memory into a Vec<u8>
. Does the std::io::BufReader<R>
documentation states that I should not use a BufReader
?
Thanks for your help.
-logan