ExpHP / rsp2

phonons in rust
Apache License 2.0
2 stars 1 forks source link

audit for functions that take `R: Read` and then construct their own `BufReader` #32

Closed ExpHP closed 6 years ago

ExpHP commented 7 years ago

https://users.rust-lang.org/t/api-taking-r-bufread-versus-taking-r-read/13821

tl;dr this is not just a bad habit, but wrong, because it can cause the function to read more than necessary in cases like reading an XYZ frame from &mut File. These should be changed to take R: BufRead

ExpHP commented 6 years ago

I did this ages ago.

There is one place that still constructs a BufRead, but it forcibly reads to EOF for the above reasons. This is documented.