Skip to content

Commit 52f099b

Browse files
committed
Avoid an intermediate allocation
1 parent 255a0de commit 52f099b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cargo/sources/registry/remote.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::cell::{RefCell, Ref, Cell};
2+
use std::fmt::Write as FmtWrite;
23
use std::io::SeekFrom;
34
use std::io::prelude::*;
45
use std::mem;
@@ -205,8 +206,7 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
205206
let config = self.config()?.unwrap();
206207
let mut url = config.dl.clone();
207208
if !url.contains(CRATE_TEMPLATE) && !url.contains(VERSION_TEMPLATE) {
208-
let suffix = format!("/{}/{}/download", CRATE_TEMPLATE, VERSION_TEMPLATE);
209-
url.push_str(&suffix);
209+
write!(url, "/{}/{}/download", CRATE_TEMPLATE, VERSION_TEMPLATE).unwrap();
210210
}
211211
let url = url
212212
.replace(CRATE_TEMPLATE, pkg.name())

0 commit comments

Comments
 (0)