codec: use libc::memchr for LinesCodec delimiter scan (#8141)

This commit is contained in:
RyanStewart
2026-06-02 17:23:18 +02:00
committed by GitHub
parent 32312ae0d6
commit 326bd2cc44
4 changed files with 109 additions and 4 deletions
+1 -3
View File
@@ -115,9 +115,7 @@ impl Decoder for LinesCodec {
// there's no max_length set, we'll read to the end of the buffer.
let read_to = cmp::min(self.max_length.saturating_add(1), buf.len());
let newline_offset = buf[self.next_index..read_to]
.iter()
.position(|b| *b == b'\n');
let newline_offset = crate::util::memchr::memchr(b'\n', &buf[self.next_index..read_to]);
match (self.is_discarding, newline_offset) {
(true, Some(offset)) => {