perf: Improve search for duplicates

Avoid owned strings where a string slice works
This commit is contained in:
Dmitry Dygalo 2022-08-31 09:58:51 +02:00
parent 1e67ce229f
commit 909cdb3ac2
No known key found for this signature in database
GPG Key ID: 0D78E60518FE18BB
1 changed files with 3 additions and 3 deletions

View File

@ -372,17 +372,17 @@ impl Visitor for Checker<'_> {
} }
// Search for duplicates. // Search for duplicates.
let mut idents: BTreeSet<String> = BTreeSet::new(); let mut idents: BTreeSet<&str> = BTreeSet::new();
for arg in all_arguments { for arg in all_arguments {
let ident = &arg.node.arg; let ident = &arg.node.arg;
if idents.contains(ident) { if idents.contains(ident.as_str()) {
self.checks.push(Check { self.checks.push(Check {
kind: CheckKind::DuplicateArgumentName, kind: CheckKind::DuplicateArgumentName,
location: arg.location, location: arg.location,
}); });
break; break;
} }
idents.insert(ident.clone()); idents.insert(ident);
} }
} }