Skip to content

Commit

Permalink
Optimize SSH key checks
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph committed Jan 29, 2024
1 parent 8bd26c7 commit 6255887
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions nexus/db-queries/src/db/datastore/ssh_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,11 @@ impl DataStore {
// doesn't exist or isn't owned by the user. Either way we want to give a specific lookup error
// for at least the first result. It would be nice to include an aggregate error with all the missing
// keys.
// TODO: Optimize the performance of this
for key in keys.iter() {
match key {
NameOrId::Name(name) => {
if !result
.iter()
.any(|(_, n)| n.clone() == name.clone().into())
.contains(|(_, n)| n.clone() == name.clone().into())
{
return Err(Error::ObjectNotFound {
type_name: ResourceType::SshKey,
Expand All @@ -80,7 +78,7 @@ impl DataStore {
}
}
NameOrId::Id(id) => {
if !result.iter().any(|(i, _)| i == id) {
if !result.contains(|(i, _)| i == id) {
return Err(Error::ObjectNotFound {
type_name: ResourceType::SshKey,
lookup_type: LookupType::ById(*id),
Expand Down

0 comments on commit 6255887

Please sign in to comment.