Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

style(that-which): refactor the matching pattern into a smart pointer

Grant Lemonsc6b0b1745d56
diff --git a/harper-core/src/linting/that_which.rs b/harper-core/src/linting/that_which.rs
index 958a6df37..e67c79029 100644
--- a/harper-core/src/linting/that_which.rs
+++ b/harper-core/src/linting/that_which.rs
@@ -15,25 +15,16 @@ impl Default for ThatWhich {
fn default() -> Self {
let mut pattern = WordPatternGroup::default();
- pattern.add(
- "that",
- Box::new(
- SequencePattern::default()
- .then_exact_word_or_lowercase("That")
- .then_whitespace()
- .then_exact_word("that"),
- ),
- );
- pattern.add(
- "That",
- Box::new(
- SequencePattern::default()
- .then_exact_word_or_lowercase("That")
- .then_whitespace()
- .then_exact_word("that"),
- ),
+ let matching_pattern = crate::Lrc::new(
+ SequencePattern::default()
+ .then_exact_word_or_lowercase("That")
+ .then_whitespace()
+ .then_exact_word("that"),
);
+ pattern.add("that", Box::new(matching_pattern.clone()));
+ pattern.add("That", Box::new(matching_pattern));
+
Self {
pattern: Box::new(pattern),
}