chore: use with_capacity
This commit is contained in:
@@ -81,7 +81,7 @@ impl DockerCmd {
|
||||
},
|
||||
};
|
||||
|
||||
let mut sub_cmd = String::new();
|
||||
let mut sub_cmd = String::with_capacity(1024);
|
||||
if let Some(mirror) = self.mirror {
|
||||
sub_cmd.push_str(&make_cmd(&mirror));
|
||||
sub_cmd.push_str("\n");
|
||||
@@ -118,7 +118,7 @@ impl DockerCmd {
|
||||
}
|
||||
|
||||
fn escape_arg(arg: &str) -> String {
|
||||
let mut r = String::new();
|
||||
let mut r = String::with_capacity(arg.len() + 10);
|
||||
r.push('\'');
|
||||
for c in arg.chars() {
|
||||
if c == '\'' {
|
||||
@@ -131,7 +131,7 @@ fn escape_arg(arg: &str) -> String {
|
||||
}
|
||||
|
||||
fn make_cmd(mirror: &str) -> String {
|
||||
let mut s = String::new();
|
||||
let mut s = String::with_capacity(256);
|
||||
s.push_str(&format!(r#"echo '[source.crates-io]
|
||||
registry = "https://github.com/rust-lang/crates.io-index"
|
||||
replace-with = "mirror"
|
||||
|
||||
Reference in New Issue
Block a user