Skip to content

Commit

Permalink
perf: use more Vec::with_capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudxain committed Dec 8, 2024
1 parent ac056dd commit 89680fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/gui/views/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ impl List {
Command::none()
}
Message::ModalValidate => {
let mut commands = vec![];
let mut commands = Vec::with_capacity(
self.selected_packages
.len()
.checked_mul(2)
.unwrap_or_else(|| unreachable!()),
);
self.selected_packages.sort_unstable();
self.selected_packages.dedup();
for selection in &self.selected_packages {
Expand Down
8 changes: 7 additions & 1 deletion src/gui/views/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,13 @@ impl Settings {
}
Message::RestoreDevice => match restore_backup(phone, packages, &self.device) {
Ok(r_packages) => {
let mut commands = vec![];
let mut commands = Vec::with_capacity(
r_packages
.len()
// assume ~2 cmds per pack
.checked_mul(2)
.unwrap_or_else(|| unreachable!()),
);
*nb_running_async_adb_commands = 0;
for p in &r_packages {
let p_info = PackageInfo {
Expand Down

0 comments on commit 89680fc

Please sign in to comment.