Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e0d014a

Browse files
committed
Auto merge of #141678 - Kobzol:revert-141516, r=workingjubilee
Revert "increase perf of charsearcher for single ascii characters" This reverts commit 245bf50 (PR #141516). It caused a large `doc` perf. regression in #141605.
2 parents ec28ae9 + cd4f199 commit e0d014a

File tree

2 files changed

+2
-32
lines changed

2 files changed

+2
-32
lines changed

‎library/core/src/str/iter.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl<'a, P: Pattern> SplitInternal<'a, P> {
656656
None
657657
}
658658

659-
#[inline(always)]
659+
#[inline]
660660
fn next(&mut self) -> Option<&'a str> {
661661
if self.finished {
662662
return None;

‎library/core/src/str/pattern.rs‎

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -429,23 +429,8 @@ unsafe impl<'a> Searcher<'a> for CharSearcher<'a> {
429429
SearchStep::Done
430430
}
431431
}
432-
#[inline(always)]
432+
#[inline]
433433
fn next_match(&mut self) -> Option<(usize, usize)> {
434-
if self.utf8_size == 1 {
435-
return match self
436-
.haystack
437-
.as_bytes()
438-
.get(self.finger..self.finger_back)?
439-
.iter()
440-
.position(|x| *x == self.utf8_encoded[0])
441-
{
442-
Some(x) => {
443-
self.finger += x + 1;
444-
Some((self.finger - 1, self.finger))
445-
}
446-
None => None,
447-
};
448-
}
449434
loop {
450435
// get the haystack after the last character found
451436
let bytes = self.haystack.as_bytes().get(self.finger..self.finger_back)?;
@@ -513,21 +498,6 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> {
513498
}
514499
#[inline]
515500
fn next_match_back(&mut self) -> Option<(usize, usize)> {
516-
if self.utf8_size == 1 {
517-
return match self
518-
.haystack
519-
.get(self.finger..self.finger_back)?
520-
.as_bytes()
521-
.iter()
522-
.rposition(|&x| x == self.utf8_encoded[0])
523-
{
524-
Some(x) => {
525-
self.finger_back = self.finger + x;
526-
Some((self.finger_back, self.finger_back + 1))
527-
}
528-
None => None,
529-
};
530-
}
531501
let haystack = self.haystack.as_bytes();
532502
loop {
533503
// get the haystack up to but not including the last character searched

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /