22//! command-line options. Structure is optimized for internal usage, as opposed
33//! to external visibility or parsing.
44
5- use std:: collections:: BTreeSet ;
65use std:: hash:: { Hash , Hasher } ;
76use std:: path:: PathBuf ;
87
8+ use fnv:: FnvHashSet ;
99use path_absolutize:: path_dedot;
1010use regex:: Regex ;
1111
@@ -24,7 +24,7 @@ pub mod user;
2424#[ derive( Debug ) ]
2525pub struct Settings {
2626 pub dummy_variable_rgx : Regex ,
27- pub enabled : BTreeSet < CheckCode > ,
27+ pub enabled : FnvHashSet < CheckCode > ,
2828 pub exclude : Vec < FilePattern > ,
2929 pub extend_exclude : Vec < FilePattern > ,
3030 pub line_length : usize ,
@@ -66,7 +66,7 @@ impl Settings {
6666 pub fn for_rule ( check_code : CheckCode ) -> Self {
6767 Self {
6868 dummy_variable_rgx : Regex :: new ( "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" ) . unwrap ( ) ,
69- enabled : BTreeSet :: from ( [ check_code] ) ,
69+ enabled : FnvHashSet :: from_iter ( [ check_code] ) ,
7070 exclude : Default :: default ( ) ,
7171 extend_exclude : Default :: default ( ) ,
7272 line_length : 88 ,
@@ -84,7 +84,7 @@ impl Settings {
8484 pub fn for_rules ( check_codes : Vec < CheckCode > ) -> Self {
8585 Self {
8686 dummy_variable_rgx : Regex :: new ( "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" ) . unwrap ( ) ,
87- enabled : BTreeSet :: from_iter ( check_codes) ,
87+ enabled : FnvHashSet :: from_iter ( check_codes) ,
8888 exclude : Default :: default ( ) ,
8989 extend_exclude : Default :: default ( ) ,
9090 line_length : 88 ,
@@ -127,8 +127,8 @@ fn resolve_codes(
127127 extend_select : & [ CheckCodePrefix ] ,
128128 ignore : & [ CheckCodePrefix ] ,
129129 extend_ignore : & [ CheckCodePrefix ] ,
130- ) -> BTreeSet < CheckCode > {
131- let mut codes: BTreeSet < CheckCode > = BTreeSet :: new ( ) ;
130+ ) -> FnvHashSet < CheckCode > {
131+ let mut codes: FnvHashSet < CheckCode > = FnvHashSet :: default ( ) ;
132132 for specificity in [
133133 PrefixSpecificity :: Category ,
134134 PrefixSpecificity :: Hundreds ,
@@ -165,7 +165,7 @@ fn resolve_codes(
165165
166166#[ cfg( test) ]
167167mod tests {
168- use std :: collections :: BTreeSet ;
168+ use fnv :: FnvHashSet ;
169169
170170 use crate :: checks:: CheckCode ;
171171 use crate :: checks_gen:: CheckCodePrefix ;
@@ -174,19 +174,19 @@ mod tests {
174174 #[ test]
175175 fn resolver ( ) {
176176 let actual = resolve_codes ( & [ CheckCodePrefix :: W ] , & [ ] , & [ ] , & [ ] ) ;
177- let expected = BTreeSet :: from_iter ( [ CheckCode :: W292 , CheckCode :: W605 ] ) ;
177+ let expected = FnvHashSet :: from_iter ( [ CheckCode :: W292 , CheckCode :: W605 ] ) ;
178178 assert_eq ! ( actual, expected) ;
179179
180180 let actual = resolve_codes ( & [ CheckCodePrefix :: W6 ] , & [ ] , & [ ] , & [ ] ) ;
181- let expected = BTreeSet :: from_iter ( [ CheckCode :: W605 ] ) ;
181+ let expected = FnvHashSet :: from_iter ( [ CheckCode :: W605 ] ) ;
182182 assert_eq ! ( actual, expected) ;
183183
184184 let actual = resolve_codes ( & [ CheckCodePrefix :: W ] , & [ ] , & [ CheckCodePrefix :: W292 ] , & [ ] ) ;
185- let expected = BTreeSet :: from_iter ( [ CheckCode :: W605 ] ) ;
185+ let expected = FnvHashSet :: from_iter ( [ CheckCode :: W605 ] ) ;
186186 assert_eq ! ( actual, expected) ;
187187
188188 let actual = resolve_codes ( & [ CheckCodePrefix :: W605 ] , & [ ] , & [ CheckCodePrefix :: W605 ] , & [ ] ) ;
189- let expected = BTreeSet :: from_iter ( [ ] ) ;
189+ let expected = FnvHashSet :: from_iter ( [ ] ) ;
190190 assert_eq ! ( actual, expected) ;
191191 }
192192}
0 commit comments