diff options
| author | Jan Verbeek <jan.verbeek@posteo.nl> | 2024-03-03 12:57:28 +0100 |
|---|---|---|
| committer | Jan Verbeek <jan.verbeek@posteo.nl> | 2024-03-03 14:32:36 +0100 |
| commit | 8212fc513c66ebd9996180456305ecd6c425d5da (patch) | |
| tree | 7ef68e157f86e69d6043b9d7823767856c88a17e /compiler/rustc_codegen_llvm/src/errors.rs | |
| parent | 3793e5ba23ca6a57ace8e3e267c22001cc5ef794 (diff) | |
| download | rust-8212fc513c66ebd9996180456305ecd6c425d5da.tar.gz rust-8212fc513c66ebd9996180456305ecd6c425d5da.zip | |
Fix quadratic behavior of repeated vectored writes
Some implementations of `Write::write_vectored` in the standard library (`BufWriter`, `LineWriter`, `Stdout`, `Stderr`) check all buffers to calculate the total length. This is O(n) over the number of buffers. It's common that only a limited number of buffers is written at a time (e.g. 1024 for `writev(2)`). `write_vectored_all` will then call `write_vectored` repeatedly, leading to a runtime of O(n²) over the number of buffers. The fix is to only calculate as much as needed if it's needed.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
