From: Steven Fackler Date: Tue, 19 Dec 2017 00:47:35 +0000 (-0800) Subject: Avoid an intermediate allocation X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~4^2~15^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=52f099b08456581967d7ba92c965ff4edb300f80;p=cargo.git Avoid an intermediate allocation --- diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index 08dcee298..6b98c9e61 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -1,4 +1,5 @@ use std::cell::{RefCell, Ref, Cell}; +use std::fmt::Write as FmtWrite; use std::io::SeekFrom; use std::io::prelude::*; use std::mem; @@ -205,8 +206,7 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { let config = self.config()?.unwrap(); let mut url = config.dl.clone(); if !url.contains(CRATE_TEMPLATE) && !url.contains(VERSION_TEMPLATE) { - let suffix = format!("/{}/{}/download", CRATE_TEMPLATE, VERSION_TEMPLATE); - url.push_str(&suffix); + write!(url, "/{}/{}/download", CRATE_TEMPLATE, VERSION_TEMPLATE).unwrap(); } let url = url .replace(CRATE_TEMPLATE, pkg.name())