Skip to content

Commit 492fed4

Browse files
author
blake2-ppc
committed
---
yaml --- r: 75705 b: refs/heads/master c: 595dd84 h: refs/heads/master i: 75703: b0da52c v: v3
1 parent 58aa2ef commit 492fed4

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: db3eb7291a3af1b88052f8ad87da79d62bd60b81
2+
refs/heads/master: 595dd843d7e2e38c08b4e03b79a0531d32d778fb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 67c954e365970e4c2cd06f0c50724656d7010f45
55
refs/heads/try: 10089455287dcc3652b984ab4bfd6971e1b5f302

trunk/src/libstd/str.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,10 +1790,8 @@ impl<'self> StrSlice<'self> for &'self str {
17901790
if search.matches(b as char) { return Some(i) }
17911791
}
17921792
} else {
1793-
let mut index = 0;
1794-
for c in self.iter() {
1793+
for (index, c) in self.char_offset_iter() {
17951794
if search.matches(c) { return Some(index); }
1796-
index += c.len_utf8_bytes();
17971795
}
17981796
}
17991797
@@ -1807,15 +1805,14 @@ impl<'self> StrSlice<'self> for &'self str {
18071805
/// `Some` containing the byte index of the last matching character
18081806
/// or `None` if there is no match
18091807
fn rfind<C: CharEq>(&self, search: C) -> Option<uint> {
1810-
let mut index = self.len();
18111808
if search.only_ascii() {
1809+
let mut index = self.len();
18121810
for b in self.byte_rev_iter() {
18131811
index -= 1;
18141812
if search.matches(b as char) { return Some(index); }
18151813
}
18161814
} else {
1817-
for c in self.rev_iter() {
1818-
index -= c.len_utf8_bytes();
1815+
for (index, c) in self.char_offset_rev_iter() {
18191816
if search.matches(c) { return Some(index); }
18201817
}
18211818
}

0 commit comments

Comments
 (0)