Skip to content

Commit ca585b9

Browse files
committed
one liners across many modules
1 parent 243851c commit ca585b9

File tree

8 files changed

+14
-17
lines changed

8 files changed

+14
-17
lines changed

regex-automata/src/nfa/thompson/compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ impl Compiler {
16631663
capture_index: u32,
16641664
name: Option<&str>,
16651665
) -> Result<StateID, BuildError> {
1666-
let name = name.map(|n| Arc::from(n));
1666+
let name = name.map(Arc::from);
16671667
self.builder.borrow_mut().add_capture_start(
16681668
StateID::ZERO,
16691669
capture_index,

regex-automata/src/nfa/thompson/pikevm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ impl PikeVM {
12901290
// the only thing in 'curr'. So we might as well just skip
12911291
// ahead until we find something that we know might advance us
12921292
// forward.
1293-
if let Some(ref pre) = pre {
1293+
if let Some(pre) = pre {
12941294
let span = Span::from(at..input.end());
12951295
match pre.find(input.haystack(), span) {
12961296
None => break,
@@ -1344,7 +1344,7 @@ impl PikeVM {
13441344
// search. If we re-computed it at every position, we would be
13451345
// simulating an unanchored search when we were tasked to perform
13461346
// an anchored search.
1347-
if (!hm.is_some() || allmatches)
1347+
if (hm.is_none() || allmatches)
13481348
&& (!anchored || at == input.start())
13491349
{
13501350
// Since we are adding to the 'curr' active states and since

regex-automata/src/util/determinize/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub(crate) fn next(
131131
if !state.look_need().is_empty() {
132132
// Add look-ahead assertions that are now true based on the current
133133
// input unit.
134-
let mut look_have = state.look_have().clone();
134+
let mut look_have = state.look_have();
135135
match unit.as_u8() {
136136
Some(b'\r') => {
137137
if !rev || !state.is_half_crlf() {

regex-automata/src/util/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl core::fmt::Debug for DebugByte {
3131
let mut len = 0;
3232
for (i, mut b) in core::ascii::escape_default(self.0).enumerate() {
3333
// capitalize \xab to \xAB
34-
if i >= 2 && b'a' <= b && b <= b'f' {
34+
if i >= 2 && (b'a'..=b'f').contains(&b) {
3535
b -= 32;
3636
}
3737
bytes[len] = b;

regex-automata/src/util/interpolate.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ pub fn string(
107107
}
108108
// Handle escaping of '$'.
109109
if replacement.as_bytes().get(1).map_or(false, |&b| b == b'$') {
110-
dst.push_str("$");
110+
dst.push('$');
111111
replacement = &replacement[2..];
112112
continue;
113113
}
114114
debug_assert!(!replacement.is_empty());
115115
let cap_ref = match find_cap_ref(replacement.as_bytes()) {
116116
Some(cap_ref) => cap_ref,
117117
None => {
118-
dst.push_str("$");
118+
dst.push('$');
119119
replacement = &replacement[1..];
120120
continue;
121121
}
@@ -321,10 +321,7 @@ fn find_cap_ref_braced(rep: &[u8], mut i: usize) -> Option<CaptureRef<'_>> {
321321
/// Returns true if and only if the given byte is allowed in a capture name
322322
/// written in non-brace form.
323323
fn is_valid_cap_letter(b: u8) -> bool {
324-
match b {
325-
b'0'..=b'9' | b'a'..=b'z' | b'A'..=b'Z' | b'_' => true,
326-
_ => false,
327-
}
324+
matches!(b, b'0'..=b'9' | b'a'..=b'z' | b'A'..=b'Z' | b'_')
328325
}
329326

330327
#[cfg(test)]

regex-automata/src/util/pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ mod inner {
678678
#[inline]
679679
pub(super) fn value(&self) -> &T {
680680
match self.value {
681-
Ok(ref v) => &**v,
681+
Ok(ref v) => v,
682682
// SAFETY: This is safe because the only way a PoolGuard gets
683683
// created for self.value=Err is when the current thread
684684
// corresponds to the owning thread, of which there can only
@@ -703,7 +703,7 @@ mod inner {
703703
#[inline]
704704
pub(super) fn value_mut(&mut self) -> &mut T {
705705
match self.value {
706-
Ok(ref mut v) => &mut **v,
706+
Ok(ref mut v) => v,
707707
// SAFETY: This is safe because the only way a PoolGuard gets
708708
// created for self.value=None is when the current thread
709709
// corresponds to the owning thread, of which there can only

regex-automata/src/util/prefilter/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,17 +478,17 @@ pub(crate) trait PrefilterI:
478478
impl<P: PrefilterI + ?Sized> PrefilterI for Arc<P> {
479479
#[cfg_attr(feature = "perf-inline", inline(always))]
480480
fn find(&self, haystack: &[u8], span: Span) -> Option<Span> {
481-
(&**self).find(haystack, span)
481+
(**self).find(haystack, span)
482482
}
483483

484484
#[cfg_attr(feature = "perf-inline", inline(always))]
485485
fn prefix(&self, haystack: &[u8], span: Span) -> Option<Span> {
486-
(&**self).prefix(haystack, span)
486+
(**self).prefix(haystack, span)
487487
}
488488

489489
#[cfg_attr(feature = "perf-inline", inline(always))]
490490
fn memory_usage(&self) -> usize {
491-
(&**self).memory_usage()
491+
(**self).memory_usage()
492492
}
493493

494494
#[cfg_attr(feature = "perf-inline", inline(always))]

regex-automata/src/util/sparse_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,6 @@ impl<'a> Iterator for SparseSetIter<'a> {
234234

235235
#[cfg_attr(feature = "perf-inline", inline(always))]
236236
fn next(&mut self) -> Option<StateID> {
237-
self.0.next().map(|&id| id)
237+
self.0.next().copied()
238238
}
239239
}

0 commit comments

Comments
 (0)