| ... | @@ -2772,10 +2772,14 @@ pub const Allocating = struct { | ... | @@ -2772,10 +2772,14 @@ pub const Allocating = struct { |
| 2772 | if (limit == .nothing) return 0; | 2772 | if (limit == .nothing) return 0; |
| 2773 | const a: *Allocating = @fieldParentPtr("writer", w); | 2773 | const a: *Allocating = @fieldParentPtr("writer", w); |
| 2774 | const pos = file_reader.logicalPos(); | 2774 | const pos = file_reader.logicalPos(); |
| 2775 | const additional = if (file_reader.getSize()) |size| size - pos else |_| std.atomic.cache_line; | 2775 | const additional, const exact = if (file_reader.getSize()) |size| |
| | 2776 | .{ size - pos, true } |
| | 2777 | else |_| |
| | 2778 | .{ std.atomic.cache_line, false }; |
| 2776 | if (additional == 0) return error.EndOfStream; | 2779 | if (additional == 0) return error.EndOfStream; |
| 2777 | a.ensureUnusedCapacity(limit.minInt64(additional)) catch return error.WriteFailed; | 2780 | a.ensureUnusedCapacity(limit.minInt64(additional)) catch return error.WriteFailed; |
| 2778 | const dest = limit.slice(a.writer.buffer[a.writer.end..]); | 2781 | const buffer = a.writer.buffer[a.writer.end..]; |
| | 2782 | const dest = if (exact) buffer[0..limit.minInt64(additional)] else limit.slice(buffer); |
| 2779 | const n = try file_reader.interface.readSliceShort(dest); | 2783 | const n = try file_reader.interface.readSliceShort(dest); |
| 2780 | if (n == 0) return error.EndOfStream; | 2784 | if (n == 0) return error.EndOfStream; |
| 2781 | a.writer.end += n; | 2785 | a.writer.end += n; |