mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
Auto merge of #141678 - Kobzol:revert-141516, r=workingjubilee
Revert "increase perf of charsearcher for single ascii characters"
This reverts commit 245bf503e2 (PR https://github.com/rust-lang/rust/pull/141516).
It caused a large `doc` perf. regression in https://github.com/rust-lang/rust/pull/141605.
This commit is contained in:
@@ -656,7 +656,7 @@ fn get_end(&mut self) -> Option<&'a str> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a str> {
|
||||
if self.finished {
|
||||
return None;
|
||||
|
||||
@@ -429,23 +429,8 @@ fn next(&mut self) -> SearchStep {
|
||||
SearchStep::Done
|
||||
}
|
||||
}
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn next_match(&mut self) -> Option<(usize, usize)> {
|
||||
if self.utf8_size == 1 {
|
||||
return match self
|
||||
.haystack
|
||||
.as_bytes()
|
||||
.get(self.finger..self.finger_back)?
|
||||
.iter()
|
||||
.position(|x| *x == self.utf8_encoded[0])
|
||||
{
|
||||
Some(x) => {
|
||||
self.finger += x + 1;
|
||||
Some((self.finger - 1, self.finger))
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
}
|
||||
loop {
|
||||
// get the haystack after the last character found
|
||||
let bytes = self.haystack.as_bytes().get(self.finger..self.finger_back)?;
|
||||
@@ -513,21 +498,6 @@ fn next_back(&mut self) -> SearchStep {
|
||||
}
|
||||
#[inline]
|
||||
fn next_match_back(&mut self) -> Option<(usize, usize)> {
|
||||
if self.utf8_size == 1 {
|
||||
return match self
|
||||
.haystack
|
||||
.get(self.finger..self.finger_back)?
|
||||
.as_bytes()
|
||||
.iter()
|
||||
.rposition(|&x| x == self.utf8_encoded[0])
|
||||
{
|
||||
Some(x) => {
|
||||
self.finger_back = self.finger + x;
|
||||
Some((self.finger_back, self.finger_back + 1))
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
}
|
||||
let haystack = self.haystack.as_bytes();
|
||||
loop {
|
||||
// get the haystack up to but not including the last character searched
|
||||
|
||||
Reference in New Issue
Block a user