From d438d36b37c939c8725f8935cc982761f002a8d9 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Tue, 4 Jul 2023 18:38:21 +0100 Subject: [PATCH] Skip bounds check for inline slices --- src/atom.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/atom.rs b/src/atom.rs index 321b0a4..d1bd7b8 100644 --- a/src/atom.rs +++ b/src/atom.rs @@ -254,8 +254,9 @@ impl ops::Deref for Atom { } INLINE_TAG => { let len = (self.unsafe_data() & LEN_MASK) >> LEN_OFFSET; + debug_assert!(len as usize <= MAX_INLINE_LEN); let src = inline_atom_slice(&self.unsafe_data); - str::from_utf8_unchecked(&src[..(len as usize)]) + str::from_utf8_unchecked(src.get_unchecked(..(len as usize))) } STATIC_TAG => Static::get().atoms[self.static_index() as usize], _ => debug_unreachable!(),