Skip to content

Commit

Permalink
perf(key_left): remove clones
Browse files Browse the repository at this point in the history
Selection access is mutable already. Operate on it directly.
  • Loading branch information
EdJoPaTo committed Jan 26, 2024
1 parent d1a2412 commit 632a95f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,11 @@ where
/// Handles the left arrow key.
/// Closes the currently selected or moves to its parent.
pub fn key_left(&mut self) {
let selected = self.selected();
if !self.close(&selected) {
let (head, _) = get_identifier_without_leaf(&selected);
self.select(head.to_vec());
// Reimplement self.close because of multiple different borrows
let changed = self.opened.remove(&self.selected);
if !changed {
// Select the parent by removing the leaf from selection
self.selected.pop();
}
}

Expand Down

0 comments on commit 632a95f

Please sign in to comment.