Commit 7a0cde9
committed
Auto merge of rust-lang#134620 - ChrisDenton:line-writer, r=tgross35
Avoid short writes in LineWriter
If the bytes written to `LineWriter` contains at least one new line but doesn't end in a new line (e.g. `"abc\ndef"`) then we:
- write up to the last new line direct to the underlying `Writer`.
- copy as many of the remaining bytes as will fit into our internal buffer.
That last step is inefficient if the remaining bytes are larger than our buffer. It will needlessly split the bytes in two, requiring at least two writes to the underlying `Writer` (one to flush the buffer, one more to write the rest). This PR skips the extra buffering if the remaining bytes are larger than the buffer.2 files changed
+21
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
123 | 130 | | |
124 | 131 | | |
125 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
847 | 847 | | |
848 | 848 | | |
849 | 849 | | |
850 | | - | |
851 | | - | |
| 850 | + | |
852 | 851 | | |
853 | 852 | | |
854 | 853 | | |
855 | 854 | | |
856 | 855 | | |
857 | 856 | | |
858 | 857 | | |
859 | | - | |
860 | | - | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
861 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
862 | 870 | | |
863 | 871 | | |
864 | 872 | | |
865 | | - | |
| 873 | + | |
866 | 874 | | |
867 | 875 | | |
868 | 876 | | |
| |||
0 commit comments