Skip to content

Commit

Permalink
Remove redundant cloning
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
  • Loading branch information
Danil-Grigorev committed Dec 28, 2024
1 parent 6b5fdcb commit ae58140
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions kube-runtime/src/reflector/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,12 @@ where
#[must_use]
pub fn remove(&self, key: &ObjectRef<K>) -> Option<Arc<K>> {
let mut store = self.store.write();
store.remove_entry(key).map(|(k, obj)| {
let mut k = k.clone();
match k.extra.remaining_lookups {
store.remove_entry(key).map(|(mut key, obj)| {
match key.extra.remaining_lookups {
Some(..=1) | None => (),
Some(lookups) => {
k.extra.remaining_lookups = Some(lookups - 1);
store.insert(k, obj.clone());
key.extra.remaining_lookups = Some(lookups - 1);
store.insert(key, obj.clone());
}
};

Expand Down

0 comments on commit ae58140

Please sign in to comment.