1
- use std:: { collections :: HashMap , hash:: Hash } ;
1
+ use std:: hash:: Hash ;
2
2
3
3
use cow_utils:: CowUtils ;
4
4
use oxc_ast:: {
@@ -9,6 +9,7 @@ use oxc_diagnostics::OxcDiagnostic;
9
9
use oxc_macros:: declare_oxc_lint;
10
10
use oxc_span:: { GetSpan , Span } ;
11
11
use regex:: Regex ;
12
+ use rustc_hash:: FxHashMap ;
12
13
13
14
use crate :: {
14
15
context:: LintContext ,
@@ -31,8 +32,8 @@ pub struct ValidTitleConfig {
31
32
ignore_type_of_describe_name : bool ,
32
33
disallowed_words : Vec < String > ,
33
34
ignore_space : bool ,
34
- must_not_match_patterns : HashMap < MatchKind , CompiledMatcherAndMessage > ,
35
- must_match_patterns : HashMap < MatchKind , CompiledMatcherAndMessage > ,
35
+ must_not_match_patterns : FxHashMap < MatchKind , CompiledMatcherAndMessage > ,
36
+ must_match_patterns : FxHashMap < MatchKind , CompiledMatcherAndMessage > ,
36
37
}
37
38
38
39
impl std:: ops:: Deref for ValidTitle {
@@ -206,14 +207,14 @@ impl MatchKind {
206
207
207
208
fn compile_matcher_patterns (
208
209
matcher_patterns : & serde_json:: Value ,
209
- ) -> Option < HashMap < MatchKind , CompiledMatcherAndMessage > > {
210
+ ) -> Option < FxHashMap < MatchKind , CompiledMatcherAndMessage > > {
210
211
matcher_patterns
211
212
. as_array ( )
212
213
. map_or_else (
213
214
|| {
214
215
// for `{ "describe": "/pattern/" }`
215
216
let obj = matcher_patterns. as_object ( ) ?;
216
- let mut map: HashMap < MatchKind , CompiledMatcherAndMessage > = HashMap :: new ( ) ;
217
+ let mut map: FxHashMap < MatchKind , CompiledMatcherAndMessage > = FxHashMap :: default ( ) ;
217
218
for ( key, value) in obj {
218
219
let Some ( v) = compile_matcher_pattern ( MatcherPattern :: String ( value) ) else {
219
220
continue ;
@@ -227,7 +228,7 @@ fn compile_matcher_patterns(
227
228
} ,
228
229
|value| {
229
230
// for `["/pattern/", "message"]`
230
- let mut map: HashMap < MatchKind , CompiledMatcherAndMessage > = HashMap :: new ( ) ;
231
+ let mut map: FxHashMap < MatchKind , CompiledMatcherAndMessage > = FxHashMap :: default ( ) ;
231
232
let v = & compile_matcher_pattern ( MatcherPattern :: Vec ( value) ) ?;
232
233
map. insert ( MatchKind :: Describe , v. clone ( ) ) ;
233
234
map. insert ( MatchKind :: Test , v. clone ( ) ) ;
@@ -239,7 +240,7 @@ fn compile_matcher_patterns(
239
240
|| {
240
241
// for `"/pattern/"`
241
242
let string = matcher_patterns. as_str ( ) ?;
242
- let mut map: HashMap < MatchKind , CompiledMatcherAndMessage > = HashMap :: new ( ) ;
243
+ let mut map: FxHashMap < MatchKind , CompiledMatcherAndMessage > = FxHashMap :: default ( ) ;
243
244
let v = & compile_matcher_pattern ( MatcherPattern :: String (
244
245
& serde_json:: Value :: String ( string. to_string ( ) ) ,
245
246
) ) ?;
0 commit comments