This avoids a redundant length check in some cases when calling `Vec::truncate` or `Vec::clear`. Fixes #51802