mirror of
https://github.com/openai/codex.git
synced 2026-10-21 03:51:43 +00:00
Use memrchr to find newlines in reverse JSONL scans (#49444)
Replace the byte-by-byte reverse newline search with `memchr::memrchr` and add `memchr` as a dependency of `codex-rollout`. GitOrigin-RevId: b07e42e15efb0d63d7b00ee9a2ee29c446f4cf59
This commit is contained in:
Generated
+1
@@ -4432,6 +4432,7 @@ dependencies = [
|
||||
"codex-utils-absolute-path",
|
||||
"codex-utils-path",
|
||||
"codex-utils-process",
|
||||
"memchr",
|
||||
"pretty_assertions",
|
||||
"regex",
|
||||
"serde",
|
||||
|
||||
@@ -25,6 +25,7 @@ codex-protocol = { workspace = true }
|
||||
codex-state = { workspace = true }
|
||||
codex-utils-absolute-path = { workspace = true }
|
||||
codex-utils-path = { workspace = true }
|
||||
memchr = { workspace = true }
|
||||
regex = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -95,7 +95,7 @@ where
|
||||
}
|
||||
|
||||
let chunk = &self.chunk[..self.chunk_position];
|
||||
if let Some(newline_position) = chunk.iter().rposition(|byte| *byte == b'\n') {
|
||||
if let Some(newline_position) = memchr::memrchr(b'\n', chunk) {
|
||||
let fragment = &chunk[newline_position + 1..];
|
||||
if !self.discarding_oversized_record {
|
||||
if self.max_record_bytes.is_some_and(|max_record_bytes| {
|
||||
|
||||
Reference in New Issue
Block a user