diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index 8b952eab2946dd6865baf946bbc546ffd25554ff..83f484dc570c468d6b0a27b4c79dc79613871d74 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -47,12 +47,7 @@ fn next(&mut self) -> Option { #[inline] fn count(self) -> usize { // length in `char` is equal to the number of non-continuation bytes - let bytes_len = self.iter.len(); - let mut cont_bytes = 0; - for &byte in self.iter { - cont_bytes += utf8_is_cont_byte(byte) as usize; - } - bytes_len - cont_bytes + self.iter.filter(|&&byte| !utf8_is_cont_byte(byte)).count() } #[inline]