Skip to content

Commit 6395398

Browse files
committed
Auto merge of #155855 - ChrisDenton:remove-unsafe-get, r=<try>
Remove unnecessary `get_unchecked`
2 parents ca9a134 + 69cc5fa commit 6395398

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

library/core/src/str/lossy.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,7 @@ impl<'a> Iterator for Utf8Chunks<'a> {
211211

212212
let mut i = 0;
213213
let mut valid_up_to = 0;
214-
while i < self.source.len() {
215-
// SAFETY: `i < self.source.len()` per previous line.
216-
// For some reason the following are both significantly slower:
217-
// while let Some(&byte) = self.source.get(i) {
218-
// while let Some(byte) = self.source.get(i).copied() {
219-
let byte = unsafe { *self.source.get_unchecked(i) };
214+
while let Some(byte) = self.source.get(i).copied() {
220215
i += 1;
221216

222217
if byte < 128 {

0 commit comments

Comments
 (0)