Skip to content

Commit 1413cac

Browse files
committed
refactor: use is_empty instead of custom function
1 parent 78d1b03 commit 1413cac

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

src/commands/grep/pattern_count/fuzzy_pc.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,9 @@ impl FuzzyPatternCounter {
4747
let mut searcher = Searcher::new_fwd();
4848

4949
// encode the patterns for each collection/searcher combination
50-
let enc_pat1 = pat1
51-
.has_patterns()
52-
.then(|| searcher_1.encode_patterns(&pat1.bytes()));
53-
let enc_pat2 = pat2
54-
.has_patterns()
55-
.then(|| searcher_2.encode_patterns(&pat2.bytes()));
56-
let enc_pat = pat
57-
.has_patterns()
58-
.then(|| searcher.encode_patterns(&pat.bytes()));
50+
let enc_pat1 = (!pat1.is_empty()).then(|| searcher_1.encode_patterns(&pat1.bytes()));
51+
let enc_pat2 = (!pat2.is_empty()).then(|| searcher_2.encode_patterns(&pat2.bytes()));
52+
let enc_pat = (!pat.is_empty()).then(|| searcher.encode_patterns(&pat.bytes()));
5953

6054
let bits1 = FixedBitSet::with_capacity(pat1.len());
6155
let bits2 = FixedBitSet::with_capacity(pat2.len());

src/commands/grep/patterns.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ impl PatternCollection {
4747
self.0.is_empty()
4848
}
4949

50-
pub fn has_patterns(&self) -> bool {
51-
!self.is_empty()
52-
}
53-
5450
pub fn iter(&self) -> std::slice::Iter<'_, Pattern> {
5551
self.0.iter()
5652
}

0 commit comments

Comments
 (0)