Skip to content

Commit 66f552c

Browse files
committed
refactor(install): avoid extra clone in InstallMethod::install
1 parent fe99f78 commit 66f552c

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/install.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,27 @@ impl<'a> InstallMethod<'a> {
3939
// Install a toolchain
4040
#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))]
4141
pub(crate) async fn install(&self) -> Result<UpdateStatus> {
42-
let nh = self.cfg().notify_handler.clone();
42+
let nh = &self.cfg().notify_handler;
4343
match self {
4444
InstallMethod::Copy { .. }
4545
| InstallMethod::Link { .. }
4646
| InstallMethod::Dist(DistOptions {
4747
old_date_version: None,
4848
..
49-
}) => (nh)(RootNotification::InstallingToolchain(&self.dest_basename())),
50-
_ => (nh)(RootNotification::UpdatingToolchain(&self.dest_basename())),
49+
}) => nh(RootNotification::InstallingToolchain(&self.dest_basename())),
50+
_ => nh(RootNotification::UpdatingToolchain(&self.dest_basename())),
5151
}
5252

53-
(self.cfg().notify_handler)(RootNotification::ToolchainDirectory(&self.dest_path()));
54-
let updated = self
55-
.run(&self.dest_path(), &|n| {
56-
(self.cfg().notify_handler)(n.into())
57-
})
58-
.await?;
53+
nh(RootNotification::ToolchainDirectory(&self.dest_path()));
54+
let updated = self.run(&self.dest_path(), &|n| nh(n.into())).await?;
5955

6056
let status = match updated {
6157
false => {
62-
(nh)(RootNotification::UpdateHashMatches);
58+
nh(RootNotification::UpdateHashMatches);
6359
UpdateStatus::Unchanged
6460
}
6561
true => {
66-
(nh)(RootNotification::InstalledToolchain(&self.dest_basename()));
62+
nh(RootNotification::InstalledToolchain(&self.dest_basename()));
6763
match self {
6864
InstallMethod::Dist(DistOptions {
6965
old_date_version: Some((_, v)),

0 commit comments

Comments
 (0)