This repository was archived by the owner on Jul 27, 2023. It is now read-only.
File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,14 @@ pub(crate) struct ArgumentList {
16
16
17
17
// Perform validation of function/lambda arguments in a function definition.
18
18
pub ( crate ) fn validate_arguments ( arguments : & ast:: Arguments ) -> Result < ( ) , LexicalError > {
19
- let mut all_arg_names = FxHashSet :: with_hasher ( Default :: default ( ) ) ;
19
+ let mut all_arg_names = FxHashSet :: with_capacity_and_hasher (
20
+ arguments. posonlyargs . len ( )
21
+ + arguments. args . len ( )
22
+ + arguments. vararg . is_some ( ) as usize
23
+ + arguments. kwonlyargs . len ( )
24
+ + arguments. kwarg . is_some ( ) as usize ,
25
+ Default :: default ( ) ,
26
+ ) ;
20
27
21
28
let posonlyargs = arguments. posonlyargs . iter ( ) ;
22
29
let args = arguments. args . iter ( ) ;
@@ -83,16 +90,14 @@ pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentLis
83
90
Some ( ( start, end, name) ) => {
84
91
// Check for duplicate keyword arguments in the call.
85
92
if let Some ( keyword_name) = & name {
86
- if keyword_names. contains ( keyword_name) {
93
+ if ! keyword_names. insert ( keyword_name. clone ( ) ) {
87
94
return Err ( LexicalError {
88
95
error : LexicalErrorType :: DuplicateKeywordArgumentError (
89
96
keyword_name. to_string ( ) ,
90
97
) ,
91
98
location : start,
92
99
} ) ;
93
100
}
94
-
95
- keyword_names. insert ( keyword_name. clone ( ) ) ;
96
101
} else {
97
102
double_starred = true ;
98
103
}
You can’t perform that action at this time.
0 commit comments