ITADN

The from_reader function has undocumented footguns for behavior and performance

#417Closedudoprog 创建于 2025-03-15
U
udoprogcommented
Notably [`from_reader`](https://docs.rs/simd-json/latest/simd_json/serde/fn.from_reader.html) reads the entire input into a buffer before attempting to parse it. This has at least two consequences which could be documented: 1. It might be slower than you'd expected, since the entirety of what's being read is copied into a new allocation. Think if something like `Cursor` is used in an attempt to bypass the `&mut [u8]` requirement in `from_slice`. 2. It consumes the whole reader, meaning it cannot be used to decode something like a stream of data with JSON inline. Not major issues, but in my mind worth noting in the documentation.
关闭于 2025-03-19 0 条评论