Skip to content

Commit 94c2de4

Browse files
committed
Apply upstream rustfmt formatting via check_rustc.sh --bless
1 parent 323b602 commit 94c2de4

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

library/core/src/str/pattern.rs

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,7 @@ unsafe impl<'a> Searcher<'a> for CharSearcher<'a> {
438438
fn next_match(&mut self) -> Option<(usize, usize)> {
439439
loop {
440440
// get the haystack after the last character found
441-
let bytes = self
442-
.haystack
443-
.as_bytes()
444-
.get(self.finger..self.finger_back)?;
441+
let bytes = self.haystack.as_bytes().get(self.finger..self.finger_back)?;
445442
// the last byte of the utf8 encoded needle
446443
// SAFETY: we have an invariant that `utf8_size < 5`
447444
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size() - 1) };
@@ -780,11 +777,7 @@ impl<C: MultiCharEq> Pattern for MultiCharEqPattern<C> {
780777

781778
#[inline]
782779
fn into_searcher(self, haystack: &str) -> MultiCharEqSearcher<'_, C> {
783-
MultiCharEqSearcher {
784-
haystack,
785-
char_eq: self.0,
786-
char_indices: haystack.char_indices(),
787-
}
780+
MultiCharEqSearcher { haystack, char_eq: self.0, char_indices: haystack.char_indices() }
788781
}
789782
}
790783

@@ -1996,11 +1989,8 @@ impl TwoWaySearcher {
19961989
}
19971990

19981991
// See if the right part of the needle matches
1999-
let start = if long_period {
2000-
self.crit_pos
2001-
} else {
2002-
cmp::max(self.crit_pos, self.memory)
2003-
};
1992+
let start =
1993+
if long_period { self.crit_pos } else { cmp::max(self.crit_pos, self.memory) };
20041994
for i in start..needle.len() {
20051995
if needle[i] != haystack[self.position + i] {
20061996
self.position += i - self.crit_pos + 1;
@@ -2130,11 +2120,7 @@ impl TwoWaySearcher {
21302120
}
21312121

21322122
// See if the right part of the needle matches
2133-
let needle_end = if long_period {
2134-
needle.len()
2135-
} else {
2136-
self.memory_back
2137-
};
2123+
let needle_end = if long_period { needle.len() } else { self.memory_back };
21382124
for i in self.crit_pos_back..needle_end {
21392125
if needle[i] != haystack[self.end - needle.len() + i] {
21402126
self.end -= self.period;
@@ -2387,9 +2373,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option<bool> {
23872373
// SAFETY: mask is between 0 and 15 trailing zeroes, we skip one additional byte that was already compared
23882374
// and then take trimmed_needle.len() bytes. This is within the bounds defined by the outer loop
23892375
unsafe {
2390-
let sub = haystack
2391-
.get_unchecked(offset..)
2392-
.get_unchecked(..trimmed_needle.len());
2376+
let sub = haystack.get_unchecked(offset..).get_unchecked(..trimmed_needle.len());
23932377
if small_slice_eq(sub, trimmed_needle) {
23942378
return true;
23952379
}
@@ -2405,12 +2389,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option<bool> {
24052389
let a: Block = unsafe { haystack.as_ptr().add(idx).cast::<Block>().read_unaligned() };
24062390
// SAFETY: this requires LANES + block_offset bytes being readable at idx
24072391
let b: Block = unsafe {
2408-
haystack
2409-
.as_ptr()
2410-
.add(idx)
2411-
.add(second_probe_offset)
2412-
.cast::<Block>()
2413-
.read_unaligned()
2392+
haystack.as_ptr().add(idx).add(second_probe_offset).cast::<Block>().read_unaligned()
24142393
};
24152394
let eq_first: Mask = a.simd_eq(first_probe);
24162395
let eq_last: Mask = b.simd_eq(second_probe);

0 commit comments

Comments
 (0)