| ... | ... | @@ -592,7 +592,16 @@ pub fn BufferedOutStreamCustom(comptime buffer_size: usize, comptime OutStreamEr |
| 592 | 592 | fn writeFn(out_stream: *Stream, bytes: []const u8) Error!void { |
| 593 | 593 | const self = @fieldParentPtr(Self, "stream", out_stream); |
| 594 | 594 | |
| 595 | | if (bytes.len >= self.buffer.len) { |
| 595 | if (bytes.len == 1) { |
| 596 | // This is not required logic but a shorter path |
| 597 | // for single byte writes |
| 598 | self.buffer[self.index] = bytes[0]; |
| 599 | self.index += 1; |
| 600 | if (self.index == buffer_size) { |
| 601 | try self.flush(); |
| 602 | } |
| 603 | return; |
| 604 | } else if (bytes.len >= self.buffer.len) { |
| 596 | 605 | try self.flush(); |
| 597 | 606 | return self.unbuffered_out_stream.write(bytes); |
| 598 | 607 | } |