From ea9dd6050463185b8d4a9022218763902abd7c1c Mon Sep 17 00:00:00 2001 From: Brad Dunbar Date: Sun, 21 Jan 2024 12:08:43 -0500 Subject: [PATCH] set len a little more concisely --- src/bytes_mut.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/bytes_mut.rs b/src/bytes_mut.rs index 88d596cf6..155d686fb 100644 --- a/src/bytes_mut.rs +++ b/src/bytes_mut.rs @@ -888,13 +888,7 @@ impl BytesMut { // new start and updating the `len` field to reflect the new length // of the view. self.ptr = vptr(self.ptr.as_ptr().add(start)); - - if self.len >= start { - self.len -= start; - } else { - self.len = 0; - } - + self.len = self.len.checked_sub(start).unwrap_or(0); self.cap -= start; }