Remove unnecessary allocations flagged by lint from rustpkg

This commit is contained in:
Seo Sanghyeon 2013-05-21 23:00:34 +09:00
parent d543354d6c
commit d4724c1a17
3 changed files with 29 additions and 29 deletions

View File

@ -126,14 +126,14 @@ impl<'self> PkgScript<'self> {
&exe, @copy os::args()[0], &exe, @copy os::args()[0],
driver::cu_everything); driver::cu_everything);
debug!("Running program: %s %s %s", exe.to_str(), root.to_str(), what); debug!("Running program: %s %s %s", exe.to_str(), root.to_str(), what);
let status = run::run_program(exe.to_str(), ~[root.to_str(), what]); let status = run::run_program(exe.to_str(), [root.to_str(), what]);
if status != 0 { if status != 0 {
return (~[], status); return (~[], status);
} }
else { else {
debug!("Running program (configs): %s %s %s", debug!("Running program (configs): %s %s %s",
exe.to_str(), root.to_str(), ~"configs"); exe.to_str(), root.to_str(), "configs");
let output = run::program_output(exe.to_str(), ~[root.to_str(), ~"configs"]); let output = run::program_output(exe.to_str(), [root.to_str(), ~"configs"]);
// Run the configs() function to get the configs // Run the configs() function to get the configs
let mut cfgs = ~[]; let mut cfgs = ~[];
for str::each_word(output.out) |w| { for str::each_word(output.out) |w| {
@ -360,9 +360,9 @@ pub fn main() {
io::println("WARNING: The Rust package manager is experimental and may be unstable"); io::println("WARNING: The Rust package manager is experimental and may be unstable");
let args = os::args(); let args = os::args();
let opts = ~[getopts::optflag(~"h"), getopts::optflag(~"help"), let opts = ~[getopts::optflag("h"), getopts::optflag("help"),
getopts::optflag(~"j"), getopts::optflag(~"json"), getopts::optflag("j"), getopts::optflag("json"),
getopts::optmulti(~"c"), getopts::optmulti(~"cfg")]; getopts::optmulti("c"), getopts::optmulti("cfg")];
let matches = &match getopts::getopts(args, opts) { let matches = &match getopts::getopts(args, opts) {
result::Ok(m) => m, result::Ok(m) => m,
result::Err(f) => { result::Err(f) => {
@ -371,10 +371,10 @@ pub fn main() {
return; return;
} }
}; };
let help = getopts::opt_present(matches, ~"h") || let help = getopts::opt_present(matches, "h") ||
getopts::opt_present(matches, ~"help"); getopts::opt_present(matches, "help");
let json = getopts::opt_present(matches, ~"j") || let json = getopts::opt_present(matches, "j") ||
getopts::opt_present(matches, ~"json"); getopts::opt_present(matches, "json");
let mut args = copy matches.free; let mut args = copy matches.free;
args.shift(); args.shift();
@ -428,7 +428,7 @@ pub impl Crate {
fn flag(&self, flag: ~str) -> Crate { fn flag(&self, flag: ~str) -> Crate {
Crate { Crate {
flags: vec::append(copy self.flags, ~[flag]), flags: vec::append(copy self.flags, [flag]),
.. copy *self .. copy *self
} }
} }
@ -442,7 +442,7 @@ pub impl Crate {
fn cfg(&self, cfg: ~str) -> Crate { fn cfg(&self, cfg: ~str) -> Crate {
Crate { Crate {
cfgs: vec::append(copy self.cfgs, ~[cfg]), cfgs: vec::append(copy self.cfgs, [cfg]),
.. copy *self .. copy *self
} }
} }
@ -546,7 +546,7 @@ impl PkgSrc {
let url = fmt!("https://%s", self.id.remote_path.to_str()); let url = fmt!("https://%s", self.id.remote_path.to_str());
util::note(fmt!("git clone %s %s", url, local.to_str())); util::note(fmt!("git clone %s %s", url, local.to_str()));
if run::program_output(~"git", ~[~"clone", copy url, local.to_str()]).status != 0 { if run::program_output("git", [~"clone", copy url, local.to_str()]).status != 0 {
util::note(fmt!("fetching %s failed: can't clone repository", url)); util::note(fmt!("fetching %s failed: can't clone repository", url));
return false; return false;
} }

View File

@ -11,7 +11,7 @@
use core::io; use core::io;
pub fn general() { pub fn general() {
io::println(~"Usage: rustpkg [options] <cmd> [args..] io::println("Usage: rustpkg [options] <cmd> [args..]
Where <cmd> is one of: Where <cmd> is one of:
build, clean, do, info, install, prefer, test, uninstall, unprefer build, clean, do, info, install, prefer, test, uninstall, unprefer
@ -23,7 +23,7 @@ Options:
} }
pub fn build() { pub fn build() {
io::println(~"rustpkg [options..] build io::println("rustpkg [options..] build
Build all targets described in the package script in the current Build all targets described in the package script in the current
directory. directory.
@ -33,21 +33,21 @@ Options:
} }
pub fn clean() { pub fn clean() {
io::println(~"rustpkg clean io::println("rustpkg clean
Remove all build files in the work cache for the package in the current Remove all build files in the work cache for the package in the current
directory."); directory.");
} }
pub fn do_cmd() { pub fn do_cmd() {
io::println(~"rustpkg do <cmd> io::println("rustpkg do <cmd>
Runs a command in the package script. You can listen to a command Runs a command in the package script. You can listen to a command
by tagging a function with the attribute `#[pkg_do(cmd)]`."); by tagging a function with the attribute `#[pkg_do(cmd)]`.");
} }
pub fn info() { pub fn info() {
io::println(~"rustpkg [options..] info io::println("rustpkg [options..] info
Probe the package script in the current directory for information. Probe the package script in the current directory for information.
@ -56,7 +56,7 @@ Options:
} }
pub fn install() { pub fn install() {
io::println(~"rustpkg [options..] install [url] [target] io::println("rustpkg [options..] install [url] [target]
Install a package from a URL by Git or cURL (FTP, HTTP, etc.). Install a package from a URL by Git or cURL (FTP, HTTP, etc.).
If target is provided, Git will checkout the branch or tag before If target is provided, Git will checkout the branch or tag before
@ -76,14 +76,14 @@ Options:
} }
pub fn uninstall() { pub fn uninstall() {
io::println(~"rustpkg uninstall <id|name>[@version] io::println("rustpkg uninstall <id|name>[@version]
Remove a package by id or name and optionally version. If the package(s) Remove a package by id or name and optionally version. If the package(s)
is/are depended on by another package then they cannot be removed."); is/are depended on by another package then they cannot be removed.");
} }
pub fn prefer() { pub fn prefer() {
io::println(~"rustpkg [options..] prefer <id|name>[@version] io::println("rustpkg [options..] prefer <id|name>[@version]
By default all binaries are given a unique name so that multiple versions can By default all binaries are given a unique name so that multiple versions can
coexist. The prefer command will symlink the uniquely named binary to coexist. The prefer command will symlink the uniquely named binary to
@ -101,7 +101,7 @@ Example:
} }
pub fn unprefer() { pub fn unprefer() {
io::println(~"rustpkg [options..] unprefer <id|name>[@version] io::println("rustpkg [options..] unprefer <id|name>[@version]
Remove all symlinks from the store to the binary directory for a package Remove all symlinks from the store to the binary directory for a package
name and optionally version. If version is not supplied, the latest version name and optionally version. If version is not supplied, the latest version
@ -110,7 +110,7 @@ information.");
} }
pub fn test() { pub fn test() {
io::println(~"rustpkg [options..] test io::println("rustpkg [options..] test
Build all targets described in the package script in the current directory Build all targets described in the package script in the current directory
with the test flag. The test bootstraps will be run afterwards and the output with the test flag. The test bootstraps will be run afterwards and the output

View File

@ -208,7 +208,7 @@ fn fold_item(ctx: @mut ReadyCtx,
fold: @fold::ast_fold) -> Option<@ast::item> { fold: @fold::ast_fold) -> Option<@ast::item> {
ctx.path.push(item.ident); ctx.path.push(item.ident);
let attrs = attr::find_attrs_by_name(item.attrs, ~"pkg_do"); let attrs = attr::find_attrs_by_name(item.attrs, "pkg_do");
if attrs.len() > 0 { if attrs.len() > 0 {
let mut cmds = ~[]; let mut cmds = ~[];
@ -281,7 +281,7 @@ pub fn note(msg: ~str) {
if term::color_supported() { if term::color_supported() {
term::fg(out, term::color_green); term::fg(out, term::color_green);
out.write_str(~"note: "); out.write_str("note: ");
term::reset(out); term::reset(out);
out.write_line(msg); out.write_line(msg);
} else { } else {
@ -294,7 +294,7 @@ pub fn warn(msg: ~str) {
if term::color_supported() { if term::color_supported() {
term::fg(out, term::color_yellow); term::fg(out, term::color_yellow);
out.write_str(~"warning: "); out.write_str("warning: ");
term::reset(out); term::reset(out);
out.write_line(msg); out.write_line(msg);
} else { } else {
@ -307,7 +307,7 @@ pub fn error(msg: ~str) {
if term::color_supported() { if term::color_supported() {
term::fg(out, term::color_red); term::fg(out, term::color_red);
out.write_str(~"error: "); out.write_str("error: ");
term::reset(out); term::reset(out);
out.write_line(msg); out.write_line(msg);
} else { } else {
@ -353,8 +353,8 @@ pub fn compile_input(sysroot: Option<@Path>,
debug!("compiling %s into %s", debug!("compiling %s into %s",
in_file.to_str(), in_file.to_str(),
out_file.to_str()); out_file.to_str());
debug!("flags: %s", str::connect(flags, ~" ")); debug!("flags: %s", str::connect(flags, " "));
debug!("cfgs: %s", str::connect(cfgs, ~" ")); debug!("cfgs: %s", str::connect(cfgs, " "));
debug!("compile_input's sysroot = %?", sysroot); debug!("compile_input's sysroot = %?", sysroot);
let crate_type = match what { let crate_type = match what {