Skip to content

Commit 49806a5

Browse files
committed
lib: more eagerly return self.len() from ceil_char_boundary
There is no reason to go through the complicated branch as it would always return `self.len()` in this case. Also helps debug code somewhat and I guess might make optimizations easier (although I haven't really a sample to demonstrate this.) ref. #93743 Suggested by @chrisduerr
1 parent a84ab0c commit 49806a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/str/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ impl str {
446446
#[unstable(feature = "round_char_boundary", issue = "93743")]
447447
#[inline]
448448
pub fn ceil_char_boundary(&self, index: usize) -> usize {
449-
if index > self.len() {
449+
if index >= self.len() {
450450
self.len()
451451
} else {
452452
let upper_bound = Ord::min(index + 4, self.len());

0 commit comments

Comments
 (0)