Skip to content

Commit c4eded6

Browse files
committed
style(databases): drop a clamp write_compact cannot reach
1 parent 00c6b1b commit c4eded6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/commands/json_rows.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ fn write_compact<W: Write>(out: &mut W, text: &str) -> std::io::Result<()> {
161161
_ => i += 1,
162162
}
163163
}
164-
// `i` can overshoot on a trailing escape, which valid JSON cannot carry.
165-
out.write_all(&bytes[copy_from.min(bytes.len())..])
164+
// Whatever follows the last gap. `copy_from` only ever takes a position
165+
// inside the row or its end, so it indexes even when a trailing escape has
166+
// carried `i` past the end — which valid JSON cannot carry anyway.
167+
out.write_all(&bytes[copy_from..])
166168
}
167169

168170
// Reads the elements of a top-level array without holding the array: serde

0 commit comments

Comments
 (0)