Skip to content

Commit 9b6b427

Browse files
committed
Update wire.rs
1 parent 094d316 commit 9b6b427

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

regex-automata/src/util/wire.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,8 @@ pub(crate) fn write_label(
482482
/// is longer than 255 bytes. (The size restriction exists so that searching
483483
/// for a label during deserialization can be done in small bounded space.)
484484
pub(crate) fn write_label_len(label: &str) -> usize {
485-
if label.len() > 255 {
486-
panic!("label must not be longer than 255 bytes");
487-
}
488-
if label.as_bytes().iter().position(|&b| b == 0).is_some() {
489-
panic!("label must not contain NUL bytes");
490-
}
485+
assert!(label.len() <= 255, "label must not be longer than 255 bytes");
486+
assert!(label.bytes().all(|b| b != 0), "label must not contain NUL bytes");
491487
let label_len = label.len() + 1; // +1 for the NUL terminator
492488
label_len + padding_len(label_len)
493489
}

0 commit comments

Comments
 (0)