| @@ -63,20 +63,20 @@ fn row_checksum(cols: List<Option<Bytes>>) -> Int { |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /// Decode the stream to its end, checksumming every row. |
| 66 | | −fn decode_stream(buffer: Bytes, acc: Int) -> Int { |
| 67 | | − match protocol.next(buffer) { |
| 66 | +fn decode_stream(buffer: Bytes, at: Int, acc: Int) -> Int { |
| 67 | + match protocol.next(buffer, at) { |
| 68 | 68 | protocol.Incomplete -> acc, |
| 69 | 69 | protocol.Malformed(e) -> panic("postgres bench: the stream is malformed: {e}"), |
| 70 | | − protocol.Message(msg, rest) -> |
| 70 | + protocol.Message(msg, next) -> |
| 71 | 71 | match msg { |
| 72 | | − protocol.DataRow(cols) -> decode_stream(rest, acc + row_checksum(cols)), |
| 72 | + protocol.DataRow(cols) -> decode_stream(buffer, next, acc + row_checksum(cols)), |
| 73 | 73 | _ -> panic("postgres bench: a message that is not a DataRow"), |
| 74 | 74 | }, |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | fn round(data: Bytes, left: Int, acc: Int) -> Int { |
| 79 | | − if left == 0 { acc } else { round(data, left - 1, acc + decode_stream(data, 0)) } |
| 79 | + if left == 0 { acc } else { round(data, left - 1, acc + decode_stream(data, 0, 0)) } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | pub fn main() -> () / <io> { |