From 8381ab7168ac31e2ae4d63548dcb62b6abba77b9 Mon Sep 17 00:00:00 2001 From: Brad Dunbar Date: Sun, 21 Jan 2024 12:13:59 -0500 Subject: [PATCH] remove redundant assertion and min We know several things here: 1. self.len <= self.cap, always 2. at <= self.len, asserted at the top of this method 3. after calling shallow_clone, other.cap == self.cap Therefore, at <= self.len <= other.cap. --- src/bytes_mut.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/bytes_mut.rs b/src/bytes_mut.rs index d167838cb..f9109d7ca 100644 --- a/src/bytes_mut.rs +++ b/src/bytes_mut.rs @@ -392,10 +392,8 @@ impl BytesMut { unsafe { let mut other = self.shallow_clone(); - assert!(at <= other.cap, "set_end out of bounds"); - other.cap = at; - other.len = cmp::min(self.len, at); + other.len = at; self.set_start(at); other }