Remove unnecessary vector allocation in `TerminalPanel::update` (#1834)

This commit is contained in:
JustForFun88 2022-12-20 00:44:05 +05:00 committed by GitHub
parent 10962a658d
commit 3c82433e7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -231,13 +231,14 @@ fn update(
self.tabs.insert(*tab_id, WidgetPod::new(split)); self.tabs.insert(*tab_id, WidgetPod::new(split));
} }
} }
for tab_id in self.tabs.keys().copied().collect::<Vec<_>>() { self.tabs.retain(|tab_id, _| {
if !data.terminal.tabs.contains_key(&tab_id) { if !data.terminal.tabs.contains_key(tab_id) {
changed = true; changed = true;
ctx.children_changed(); ctx.children_changed();
self.tabs.remove(&tab_id); return false;
} }
} true
});
if changed && !self.tabs.is_empty() { if changed && !self.tabs.is_empty() {
ctx.submit_command(Command::new( ctx.submit_command(Command::new(
LAPCE_UI_COMMAND, LAPCE_UI_COMMAND,