perf(key_left): remove clones

Selection access is mutable already. Operate on it directly.
This commit is contained in:
EdJoPaTo
2024-01-26 05:22:20 +01:00
parent d1a241266f
commit 632a95f853
+5 -4
View File
@@ -216,10 +216,11 @@ where
/// Handles the left arrow key. /// Handles the left arrow key.
/// Closes the currently selected or moves to its parent. /// Closes the currently selected or moves to its parent.
pub fn key_left(&mut self) { pub fn key_left(&mut self) {
let selected = self.selected(); // Reimplement self.close because of multiple different borrows
if !self.close(&selected) { let changed = self.opened.remove(&self.selected);
let (head, _) = get_identifier_without_leaf(&selected); if !changed {
self.select(head.to_vec()); // Select the parent by removing the leaf from selection
self.selected.pop();
} }
} }