Remove a bunch of unnecessary allocations and copies
This commit is contained in:
parent
ca74cbdc5c
commit
1720d9f663
27 changed files with 83 additions and 91 deletions
|
@ -99,7 +99,7 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fn xfail_target() -> ~str {
|
fn xfail_target() -> ~str {
|
||||||
~"xfail-" + str::to_owned(os::SYSNAME)
|
~"xfail-" + os::SYSNAME
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
|
||||||
|
|
||||||
fn parse_name_value_directive(line: &str,
|
fn parse_name_value_directive(line: &str,
|
||||||
directive: ~str) -> Option<~str> {
|
directive: ~str) -> Option<~str> {
|
||||||
let keycolon = directive + ~":";
|
let keycolon = directive + ":";
|
||||||
match str::find_str(line, keycolon) {
|
match str::find_str(line, keycolon) {
|
||||||
Some(colon) => {
|
Some(colon) => {
|
||||||
let value = str::slice(line, colon + str::len(keycolon),
|
let value = str::slice(line, colon + str::len(keycolon),
|
||||||
|
|
|
@ -24,12 +24,12 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
|
||||||
let mut env = os::env();
|
let mut env = os::env();
|
||||||
|
|
||||||
// Make sure we include the aux directory in the path
|
// Make sure we include the aux directory in the path
|
||||||
assert!(prog.ends_with(~".exe"));
|
assert!(prog.ends_with(".exe"));
|
||||||
let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ~".libaux";
|
let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ".libaux";
|
||||||
|
|
||||||
env = do vec::map(env) |pair| {
|
env = do vec::map(env) |pair| {
|
||||||
let (k,v) = *pair;
|
let (k,v) = *pair;
|
||||||
if k == ~"PATH" { (~"PATH", v + ~";" + lib_path + ~";" + aux_path) }
|
if k == ~"PATH" { (~"PATH", v + ";" + lib_path + ";" + aux_path) }
|
||||||
else { (k,v) }
|
else { (k,v) }
|
||||||
};
|
};
|
||||||
if str::ends_with(prog, "rustc.exe") {
|
if str::ends_with(prog, "rustc.exe") {
|
||||||
|
|
|
@ -378,7 +378,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
|
||||||
was_expected = true;
|
was_expected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !was_expected && is_compiler_error_or_warning(str::to_owned(line)) {
|
if !was_expected && is_compiler_error_or_warning(line) {
|
||||||
fatal_ProcRes(fmt!("unexpected compiler error or warning: '%s'",
|
fatal_ProcRes(fmt!("unexpected compiler error or warning: '%s'",
|
||||||
line),
|
line),
|
||||||
ProcRes);
|
ProcRes);
|
||||||
|
@ -596,8 +596,7 @@ fn make_lib_name(config: &config, auxfile: &Path, testfile: &Path) -> Path {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_exe_name(config: &config, testfile: &Path) -> Path {
|
fn make_exe_name(config: &config, testfile: &Path) -> Path {
|
||||||
Path(output_base_name(config, testfile).to_str() +
|
Path(output_base_name(config, testfile).to_str() + os::EXE_SUFFIX)
|
||||||
str::to_owned(os::EXE_SUFFIX))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
|
fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
|
||||||
|
@ -606,7 +605,7 @@ fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
|
||||||
// then split apart its command
|
// then split apart its command
|
||||||
let toolargs = split_maybe_args(&config.runtool);
|
let toolargs = split_maybe_args(&config.runtool);
|
||||||
|
|
||||||
let mut args = toolargs + ~[make_exe_name(config, testfile).to_str()];
|
let mut args = toolargs + [make_exe_name(config, testfile).to_str()];
|
||||||
let prog = args.shift();
|
let prog = args.shift();
|
||||||
return ProcArgs {prog: prog, args: args};
|
return ProcArgs {prog: prog, args: args};
|
||||||
}
|
}
|
||||||
|
@ -655,7 +654,7 @@ fn make_cmdline(_libpath: &str, prog: &str, args: &[~str]) -> ~str {
|
||||||
#[cfg(target_os = "win32")]
|
#[cfg(target_os = "win32")]
|
||||||
fn make_cmdline(libpath: &str, prog: &str, args: &[~str]) -> ~str {
|
fn make_cmdline(libpath: &str, prog: &str, args: &[~str]) -> ~str {
|
||||||
fmt!("%s %s %s", lib_path_cmd_prefix(libpath), prog,
|
fmt!("%s %s %s", lib_path_cmd_prefix(libpath), prog,
|
||||||
str::connect(args, ~" "))
|
str::connect(args, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
|
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
|
||||||
|
@ -776,8 +775,8 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
|
||||||
for args.args.each |tv| {
|
for args.args.each |tv| {
|
||||||
newcmd_out.push_str(" ");
|
newcmd_out.push_str(" ");
|
||||||
newcmd_err.push_str(" ");
|
newcmd_err.push_str(" ");
|
||||||
newcmd_out.push_str(tv.to_owned());
|
newcmd_out.push_str(*tv);
|
||||||
newcmd_err.push_str(tv.to_owned());
|
newcmd_err.push_str(*tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
newcmd_out.push_str(" 2>/dev/null");
|
newcmd_out.push_str(" 2>/dev/null");
|
||||||
|
|
|
@ -110,10 +110,11 @@ pub struct Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mkname(nm: &str) -> Name {
|
fn mkname(nm: &str) -> Name {
|
||||||
let unm = str::to_owned(nm);
|
if nm.len() == 1u {
|
||||||
return if nm.len() == 1u {
|
Short(str::char_at(nm, 0u))
|
||||||
Short(str::char_at(unm, 0u))
|
} else {
|
||||||
} else { Long(unm) };
|
Long(nm.to_owned())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create an option that is required and takes an argument
|
/// Create an option that is required and takes an argument
|
||||||
|
@ -195,19 +196,19 @@ pub enum Fail_ {
|
||||||
pub fn fail_str(f: Fail_) -> ~str {
|
pub fn fail_str(f: Fail_) -> ~str {
|
||||||
return match f {
|
return match f {
|
||||||
ArgumentMissing(ref nm) => {
|
ArgumentMissing(ref nm) => {
|
||||||
~"Argument to option '" + *nm + "' missing."
|
fmt!("Argument to option '%s' missing.", *nm)
|
||||||
}
|
}
|
||||||
UnrecognizedOption(ref nm) => {
|
UnrecognizedOption(ref nm) => {
|
||||||
~"Unrecognized option: '" + *nm + "'."
|
fmt!("Unrecognized option: '%s'.", *nm)
|
||||||
}
|
}
|
||||||
OptionMissing(ref nm) => {
|
OptionMissing(ref nm) => {
|
||||||
~"Required option '" + *nm + "' missing."
|
fmt!("Required option '%s' missing.", *nm)
|
||||||
}
|
}
|
||||||
OptionDuplicated(ref nm) => {
|
OptionDuplicated(ref nm) => {
|
||||||
~"Option '" + *nm + "' given more than once."
|
fmt!("Option '%s' given more than once.", *nm)
|
||||||
}
|
}
|
||||||
UnexpectedArgument(ref nm) => {
|
UnexpectedArgument(ref nm) => {
|
||||||
~"Option " + *nm + " does not take an argument."
|
fmt!("Option '%s' does not take an argument.", *nm)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -245,11 +246,11 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
|
||||||
let mut names;
|
let mut names;
|
||||||
let mut i_arg = None;
|
let mut i_arg = None;
|
||||||
if cur[1] == '-' as u8 {
|
if cur[1] == '-' as u8 {
|
||||||
let tail = str::slice(cur, 2, curlen).to_owned();
|
let tail = str::slice(cur, 2, curlen);
|
||||||
let mut tail_eq = ~[];
|
let mut tail_eq = ~[];
|
||||||
for str::each_splitn_char(tail, '=', 1) |s| { tail_eq.push(s.to_owned()) }
|
for str::each_splitn_char(tail, '=', 1) |s| { tail_eq.push(s.to_owned()) }
|
||||||
if tail_eq.len() <= 1 {
|
if tail_eq.len() <= 1 {
|
||||||
names = ~[Long(tail)];
|
names = ~[Long(tail.to_owned())];
|
||||||
} else {
|
} else {
|
||||||
names =
|
names =
|
||||||
~[Long(copy tail_eq[0])];
|
~[Long(copy tail_eq[0])];
|
||||||
|
|
|
@ -230,7 +230,7 @@ pub mod v4 {
|
||||||
let input_is_inaddr_none =
|
let input_is_inaddr_none =
|
||||||
result::get(&ip_rep_result).as_u32() == INADDR_NONE;
|
result::get(&ip_rep_result).as_u32() == INADDR_NONE;
|
||||||
|
|
||||||
let new_addr = uv_ip4_addr(str::to_owned(ip), 22);
|
let new_addr = uv_ip4_addr(ip, 22);
|
||||||
let reformatted_name = uv_ip4_name(&new_addr);
|
let reformatted_name = uv_ip4_name(&new_addr);
|
||||||
debug!("try_parse_addr: input ip: %s reparsed ip: %s",
|
debug!("try_parse_addr: input ip: %s reparsed ip: %s",
|
||||||
ip, reformatted_name);
|
ip, reformatted_name);
|
||||||
|
@ -259,7 +259,6 @@ pub mod v6 {
|
||||||
use uv_ip6_name = uv::ll::ip6_name;
|
use uv_ip6_name = uv::ll::ip6_name;
|
||||||
|
|
||||||
use core::result;
|
use core::result;
|
||||||
use core::str;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a str to `ip_addr`
|
* Convert a str to `ip_addr`
|
||||||
|
@ -285,7 +284,7 @@ pub mod v6 {
|
||||||
pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
|
pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
|
||||||
unsafe {
|
unsafe {
|
||||||
// need to figure out how to establish a parse failure..
|
// need to figure out how to establish a parse failure..
|
||||||
let new_addr = uv_ip6_addr(str::to_owned(ip), 22);
|
let new_addr = uv_ip6_addr(ip, 22);
|
||||||
let reparsed_name = uv_ip6_name(&new_addr);
|
let reparsed_name = uv_ip6_name(&new_addr);
|
||||||
debug!("v6::try_parse_addr ip: '%s' reparsed '%s'",
|
debug!("v6::try_parse_addr ip: '%s' reparsed '%s'",
|
||||||
ip, reparsed_name);
|
ip, reparsed_name);
|
||||||
|
|
|
@ -585,7 +585,7 @@ fn get_path(rawurl: &str, authority: bool) ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok((decode_component(str::slice(rawurl, 0, end).to_owned()),
|
return Ok((decode_component(str::slice(rawurl, 0, end)),
|
||||||
str::slice(rawurl, end, len).to_owned()));
|
str::slice(rawurl, end, len).to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,14 +596,13 @@ fn get_query_fragment(rawurl: &str) ->
|
||||||
if str::starts_with(rawurl, "#") {
|
if str::starts_with(rawurl, "#") {
|
||||||
let f = decode_component(str::slice(rawurl,
|
let f = decode_component(str::slice(rawurl,
|
||||||
1,
|
1,
|
||||||
str::len(rawurl)).to_owned());
|
str::len(rawurl)));
|
||||||
return Ok((~[], Some(f)));
|
return Ok((~[], Some(f)));
|
||||||
} else {
|
} else {
|
||||||
return Ok((~[], None));
|
return Ok((~[], None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let (q, r) = split_char_first(str::slice(rawurl, 1,
|
let (q, r) = split_char_first(str::slice(rawurl, 1, rawurl.len()), '#');
|
||||||
str::len(rawurl)).to_owned(), '#');
|
|
||||||
let f = if str::len(r) != 0 {
|
let f = if str::len(r) != 0 {
|
||||||
Some(decode_component(r)) } else { None };
|
Some(decode_component(r)) } else { None };
|
||||||
return Ok((query_from_str(q), f));
|
return Ok((query_from_str(q), f));
|
||||||
|
|
|
@ -399,8 +399,7 @@ mod tests {
|
||||||
let mut left = len;
|
let mut left = len;
|
||||||
while left > 0u {
|
while left > 0u {
|
||||||
let take = (left + 1u) / 2u;
|
let take = (left + 1u) / 2u;
|
||||||
sh.input_str(str::slice(t.input, len - left,
|
sh.input_str(t.input.slice(len - left, take + len - left));
|
||||||
take + len - left).to_owned());
|
|
||||||
left = left - take;
|
left = left - take;
|
||||||
}
|
}
|
||||||
let out = sh.result();
|
let out = sh.result();
|
||||||
|
|
|
@ -293,7 +293,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
|
||||||
|
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
while i < digits {
|
while i < digits {
|
||||||
let range = str::char_range_at(str::to_owned(ss), pos);
|
let range = str::char_range_at(ss, pos);
|
||||||
pos = range.next;
|
pos = range.next;
|
||||||
|
|
||||||
match range.ch {
|
match range.ch {
|
||||||
|
@ -632,7 +632,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
do io::with_str_reader(str::to_owned(format)) |rdr| {
|
do io::with_str_reader(format) |rdr| {
|
||||||
let mut tm = Tm {
|
let mut tm = Tm {
|
||||||
tm_sec: 0_i32,
|
tm_sec: 0_i32,
|
||||||
tm_min: 0_i32,
|
tm_min: 0_i32,
|
||||||
|
@ -844,7 +844,7 @@ priv fn do_strftime(format: &str, tm: &Tm) -> ~str {
|
||||||
|
|
||||||
let mut buf = ~"";
|
let mut buf = ~"";
|
||||||
|
|
||||||
do io::with_str_reader(str::to_owned(format)) |rdr| {
|
do io::with_str_reader(format) |rdr| {
|
||||||
while !rdr.eof() {
|
while !rdr.eof() {
|
||||||
match rdr.read_char() {
|
match rdr.read_char() {
|
||||||
'%' => buf += parse_type(rdr.read_char(), tm),
|
'%' => buf += parse_type(rdr.read_char(), tm),
|
||||||
|
|
|
@ -201,7 +201,7 @@ struct Logger {
|
||||||
|
|
||||||
pub impl Logger {
|
pub impl Logger {
|
||||||
fn info(&self, i: &str) {
|
fn info(&self, i: &str) {
|
||||||
io::println(~"workcache: " + i.to_owned());
|
io::println(~"workcache: " + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -741,7 +741,6 @@ pub fn mangle_internal_name_by_seq(ccx: @CrateContext, flav: &str) -> ~str {
|
||||||
|
|
||||||
|
|
||||||
pub fn output_dll_filename(os: session::os, lm: LinkMeta) -> ~str {
|
pub fn output_dll_filename(os: session::os, lm: LinkMeta) -> ~str {
|
||||||
let libname = fmt!("%s-%s-%s", lm.name, lm.extras_hash, lm.vers);
|
|
||||||
let (dll_prefix, dll_suffix) = match os {
|
let (dll_prefix, dll_suffix) = match os {
|
||||||
session::os_win32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
|
session::os_win32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
|
||||||
session::os_macos => (macos::DLL_PREFIX, macos::DLL_SUFFIX),
|
session::os_macos => (macos::DLL_PREFIX, macos::DLL_SUFFIX),
|
||||||
|
@ -749,8 +748,7 @@ pub fn output_dll_filename(os: session::os, lm: LinkMeta) -> ~str {
|
||||||
session::os_android => (android::DLL_PREFIX, android::DLL_SUFFIX),
|
session::os_android => (android::DLL_PREFIX, android::DLL_SUFFIX),
|
||||||
session::os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
|
session::os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
|
||||||
};
|
};
|
||||||
return str::to_owned(dll_prefix) + libname +
|
fmt!("%s%s-%s-%s%s", dll_prefix, lm.name, lm.extras_hash, lm.vers, dll_suffix)
|
||||||
str::to_owned(dll_suffix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user wants an exe generated we need to invoke
|
// If the user wants an exe generated we need to invoke
|
||||||
|
|
|
@ -2014,7 +2014,7 @@ pub fn type_to_str_inner(names: @TypeNames, outer0: &[TypeRef], ty: TypeRef)
|
||||||
let mut first: bool = true;
|
let mut first: bool = true;
|
||||||
for tys.each |t| {
|
for tys.each |t| {
|
||||||
if first { first = false; } else { s += ", "; }
|
if first { first = false; } else { s += ", "; }
|
||||||
s += type_to_str_inner(names, outer, *t).to_owned();
|
s += type_to_str_inner(names, outer, *t);
|
||||||
}
|
}
|
||||||
// [Note at-str] FIXME #2543: Could rewrite this without the copy,
|
// [Note at-str] FIXME #2543: Could rewrite this without the copy,
|
||||||
// but need better @str support.
|
// but need better @str support.
|
||||||
|
|
|
@ -268,8 +268,7 @@ pub fn list_file_metadata(intr: @ident_interner,
|
||||||
match get_metadata_section(os, path) {
|
match get_metadata_section(os, path) {
|
||||||
option::Some(bytes) => decoder::list_crate_metadata(intr, bytes, out),
|
option::Some(bytes) => decoder::list_crate_metadata(intr, bytes, out),
|
||||||
option::None => {
|
option::None => {
|
||||||
out.write_str(~"could not find metadata in "
|
out.write_str(fmt!("could not find metadata in %s.\n", path.to_str()))
|
||||||
+ path.to_str() + ".\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,7 @@ pub fn enc_ty(w: @io::Writer, cx: @ctxt, t: ty::t) {
|
||||||
let abbrev_len = 3u + estimate_sz(pos) + estimate_sz(len);
|
let abbrev_len = 3u + estimate_sz(pos) + estimate_sz(len);
|
||||||
if abbrev_len < len {
|
if abbrev_len < len {
|
||||||
// I.e. it's actually an abbreviation.
|
// I.e. it's actually an abbreviation.
|
||||||
let s = ~"#" + uint::to_str_radix(pos, 16u) + ":" +
|
let s = fmt!("#%x:%x#", pos, len);
|
||||||
uint::to_str_radix(len, 16u) + "#";
|
|
||||||
let a = ty_abbrev { pos: pos, len: len, s: @s };
|
let a = ty_abbrev { pos: pos, len: len, s: @s };
|
||||||
abbrevs.insert(t, a);
|
abbrevs.insert(t, a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,8 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
|
||||||
|
|
||||||
// Add the clobbers to our constraints list
|
// Add the clobbers to our constraints list
|
||||||
if clobbers != ~"" && constraints != ~"" {
|
if clobbers != ~"" && constraints != ~"" {
|
||||||
constraints += ~"," + clobbers;
|
constraints += ",";
|
||||||
|
constraints += clobbers;
|
||||||
} else {
|
} else {
|
||||||
constraints += clobbers;
|
constraints += clobbers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2906,8 +2906,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
|
||||||
let cstore = sess.cstore;
|
let cstore = sess.cstore;
|
||||||
while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
|
while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
|
||||||
let mapname = if *sess.building_library {
|
let mapname = if *sess.building_library {
|
||||||
mapmeta.name.to_owned() + "_" + mapmeta.vers.to_owned() + "_"
|
fmt!("%s_%s_%s", mapmeta.name, mapmeta.vers, mapmeta.extras_hash)
|
||||||
+ mapmeta.extras_hash.to_owned()
|
|
||||||
} else {
|
} else {
|
||||||
~"toplevel"
|
~"toplevel"
|
||||||
};
|
};
|
||||||
|
|
|
@ -60,8 +60,8 @@ pub impl FnType {
|
||||||
fn build_shim_args(&self, bcx: block,
|
fn build_shim_args(&self, bcx: block,
|
||||||
arg_tys: &[TypeRef],
|
arg_tys: &[TypeRef],
|
||||||
llargbundle: ValueRef) -> ~[ValueRef] {
|
llargbundle: ValueRef) -> ~[ValueRef] {
|
||||||
let mut atys = /*bad*/copy self.arg_tys;
|
let mut atys: &[LLVMType] = self.arg_tys;
|
||||||
let mut attrs = /*bad*/copy self.attrs;
|
let mut attrs: &[option::Option<Attribute>] = self.attrs;
|
||||||
|
|
||||||
let mut llargvals = ~[];
|
let mut llargvals = ~[];
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
|
@ -71,8 +71,8 @@ pub impl FnType {
|
||||||
let llretptr = GEPi(bcx, llargbundle, [0u, n]);
|
let llretptr = GEPi(bcx, llargbundle, [0u, n]);
|
||||||
let llretloc = Load(bcx, llretptr);
|
let llretloc = Load(bcx, llretptr);
|
||||||
llargvals = ~[llretloc];
|
llargvals = ~[llretloc];
|
||||||
atys = vec::to_owned(atys.tail());
|
atys = atys.tail();
|
||||||
attrs = vec::to_owned(attrs.tail());
|
attrs = attrs.tail();
|
||||||
}
|
}
|
||||||
|
|
||||||
while i < n {
|
while i < n {
|
||||||
|
@ -133,12 +133,12 @@ pub impl FnType {
|
||||||
ret_ty: TypeRef,
|
ret_ty: TypeRef,
|
||||||
llwrapfn: ValueRef,
|
llwrapfn: ValueRef,
|
||||||
llargbundle: ValueRef) {
|
llargbundle: ValueRef) {
|
||||||
let mut atys = /*bad*/copy self.arg_tys;
|
let mut atys: &[LLVMType] = self.arg_tys;
|
||||||
let mut attrs = /*bad*/copy self.attrs;
|
let mut attrs: &[option::Option<Attribute>] = self.attrs;
|
||||||
let mut j = 0u;
|
let mut j = 0u;
|
||||||
let llretptr = if self.sret {
|
let llretptr = if self.sret {
|
||||||
atys = vec::to_owned(atys.tail());
|
atys = atys.tail();
|
||||||
attrs = vec::to_owned(attrs.tail());
|
attrs = attrs.tail();
|
||||||
j = 1u;
|
j = 1u;
|
||||||
get_param(llwrapfn, 0u)
|
get_param(llwrapfn, 0u)
|
||||||
} else if self.ret_ty.cast {
|
} else if self.ret_ty.cast {
|
||||||
|
|
|
@ -3661,8 +3661,8 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
|
||||||
~"bswap64" => (0, ~[ ty::mk_i64() ], ty::mk_i64()),
|
~"bswap64" => (0, ~[ ty::mk_i64() ], ty::mk_i64()),
|
||||||
ref other => {
|
ref other => {
|
||||||
tcx.sess.span_err(it.span,
|
tcx.sess.span_err(it.span,
|
||||||
~"unrecognized intrinsic function: `" +
|
fmt!("unrecognized intrinsic function: `%s`",
|
||||||
(*other) + "`");
|
*other));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -323,8 +323,8 @@ fn check_main_fn_ty(ccx: @mut CrateCtxt,
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess.span_bug(main_span,
|
tcx.sess.span_bug(main_span,
|
||||||
~"main has a non-function type: found `" +
|
fmt!("main has a non-function type: found `%s`",
|
||||||
ppaux::ty_to_str(tcx, main_t) + "`");
|
ppaux::ty_to_str(tcx, main_t)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,8 +372,8 @@ fn check_start_fn_ty(ccx: @mut CrateCtxt,
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess.span_bug(start_span,
|
tcx.sess.span_bug(start_span,
|
||||||
~"start has a non-function type: found `" +
|
fmt!("start has a non-function type: found `%s`",
|
||||||
ppaux::ty_to_str(tcx, start_t) + "`");
|
ppaux::ty_to_str(tcx, start_t)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -416,7 +416,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
|
||||||
ty_rptr(r, ref tm) => {
|
ty_rptr(r, ref tm) => {
|
||||||
region_to_str_space(cx, "&", r) + mt_to_str(cx, tm)
|
region_to_str_space(cx, "&", r) + mt_to_str(cx, tm)
|
||||||
}
|
}
|
||||||
ty_unboxed_vec(ref tm) => { ~"unboxed_vec<" + mt_to_str(cx, tm) + ">" }
|
ty_unboxed_vec(ref tm) => { fmt!("unboxed_vec<%s>", mt_to_str(cx, tm)) }
|
||||||
ty_type => ~"type",
|
ty_type => ~"type",
|
||||||
ty_tup(ref elems) => {
|
ty_tup(ref elems) => {
|
||||||
let strs = elems.map(|elem| ty_to_str(cx, *elem));
|
let strs = elems.map(|elem| ty_to_str(cx, *elem));
|
||||||
|
|
|
@ -272,12 +272,11 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
|
||||||
}
|
}
|
||||||
~"help" => {
|
~"help" => {
|
||||||
println(
|
println(
|
||||||
~":{\\n ..lines.. \\n:}\\n - execute multiline command\n" +
|
":{\\n ..lines.. \\n:}\\n - execute multiline command\n\
|
||||||
":load <crate> ... - \
|
:load <crate> ... - loads given crates as dynamic libraries\n\
|
||||||
loads given crates as dynamic libraries\n" +
|
:clear - clear the bindings\n\
|
||||||
":clear - clear the bindings\n" +
|
:exit - exit from the repl\n\
|
||||||
":exit - exit from the repl\n" +
|
:help - show this message");
|
||||||
":help - show this message");
|
|
||||||
}
|
}
|
||||||
~"load" => {
|
~"load" => {
|
||||||
let mut loaded_crates: ~[~str] = ~[];
|
let mut loaded_crates: ~[~str] = ~[];
|
||||||
|
|
|
@ -145,7 +145,7 @@ pub mod win32 {
|
||||||
pub fn as_utf16_p<T>(s: &str, f: &fn(*u16) -> T) -> T {
|
pub fn as_utf16_p<T>(s: &str, f: &fn(*u16) -> T) -> T {
|
||||||
let mut t = str::to_utf16(s);
|
let mut t = str::to_utf16(s);
|
||||||
// Null terminate before passing on.
|
// Null terminate before passing on.
|
||||||
t += ~[0u16];
|
t += [0u16];
|
||||||
vec::as_imm_buf(t, |buf, _len| f(buf))
|
vec::as_imm_buf(t, |buf, _len| f(buf))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,8 +437,7 @@ fn dup2(src: c_int, dst: c_int) -> c_int {
|
||||||
|
|
||||||
/// Returns the proper dll filename for the given basename of a file.
|
/// Returns the proper dll filename for the given basename of a file.
|
||||||
pub fn dll_filename(base: &str) -> ~str {
|
pub fn dll_filename(base: &str) -> ~str {
|
||||||
return str::to_owned(DLL_PREFIX) + str::to_owned(base) +
|
fmt!("%s%s%s", DLL_PREFIX, base, DLL_SUFFIX)
|
||||||
str::to_owned(DLL_SUFFIX)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optionally returns the filesystem path to the current executable which is
|
/// Optionally returns the filesystem path to the current executable which is
|
||||||
|
|
|
@ -448,7 +448,8 @@ fn scan_number(c: char, rdr: @mut StringReader) -> token::Token {
|
||||||
is_float = true;
|
is_float = true;
|
||||||
bump(rdr);
|
bump(rdr);
|
||||||
let dec_part = scan_digits(rdr, 10u);
|
let dec_part = scan_digits(rdr, 10u);
|
||||||
num_str += ~"." + dec_part;
|
num_str += ".";
|
||||||
|
num_str += dec_part;
|
||||||
}
|
}
|
||||||
if is_float {
|
if is_float {
|
||||||
match base {
|
match base {
|
||||||
|
|
|
@ -26,8 +26,8 @@ fn print_complements() {
|
||||||
let all = ~[Blue, Red, Yellow];
|
let all = ~[Blue, Red, Yellow];
|
||||||
for vec::each(all) |aa| {
|
for vec::each(all) |aa| {
|
||||||
for vec::each(all) |bb| {
|
for vec::each(all) |bb| {
|
||||||
io::println(show_color(*aa) + ~" + " + show_color(*bb) +
|
io::println(show_color(*aa) + " + " + show_color(*bb) +
|
||||||
~" -> " + show_color(transform(*aa, *bb)));
|
" -> " + show_color(transform(*aa, *bb)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ fn show_color(cc: color) -> ~str {
|
||||||
fn show_color_list(set: ~[color]) -> ~str {
|
fn show_color_list(set: ~[color]) -> ~str {
|
||||||
let mut out = ~"";
|
let mut out = ~"";
|
||||||
for vec::eachi(set) |_ii, col| {
|
for vec::eachi(set) |_ii, col| {
|
||||||
out += ~" ";
|
out += " ";
|
||||||
out += show_color(*col);
|
out += show_color(*col);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
@ -82,7 +82,7 @@ fn show_number(nn: uint) -> ~str {
|
||||||
while num != 0 {
|
while num != 0 {
|
||||||
dig = num % 10;
|
dig = num % 10;
|
||||||
num = num / 10;
|
num = num / 10;
|
||||||
out = show_digit(dig) + ~" " + out;
|
out = show_digit(dig) + " " + out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
@ -131,8 +131,8 @@ fn creature(
|
||||||
}
|
}
|
||||||
option::None => {
|
option::None => {
|
||||||
// log creatures met and evil clones of self
|
// log creatures met and evil clones of self
|
||||||
let report = fmt!("%u", creatures_met) + ~" " +
|
let report = fmt!("%u %s",
|
||||||
show_number(evil_clones_met);
|
creatures_met, show_number(evil_clones_met));
|
||||||
to_rendezvous_log.send(report);
|
to_rendezvous_log.send(report);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ fn make_cumulative(aa: ~[AminoAcids]) -> ~[AminoAcids] {
|
||||||
let mut ans: ~[AminoAcids] = ~[];
|
let mut ans: ~[AminoAcids] = ~[];
|
||||||
for aa.each |a| {
|
for aa.each |a| {
|
||||||
cp += a.prob;
|
cp += a.prob;
|
||||||
ans += ~[AminoAcids {ch: a.ch, prob: cp}];
|
ans += [AminoAcids {ch: a.ch, prob: cp}];
|
||||||
}
|
}
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ fn make_random_fasta(wr: @io::Writer,
|
||||||
desc: ~str,
|
desc: ~str,
|
||||||
genelist: ~[AminoAcids],
|
genelist: ~[AminoAcids],
|
||||||
n: int) {
|
n: int) {
|
||||||
wr.write_line(~">" + id + ~" " + desc);
|
wr.write_line(~">" + id + " " + desc);
|
||||||
let mut rng = rand::rng();
|
let mut rng = rand::rng();
|
||||||
let rng = @mut MyRandom {
|
let rng = @mut MyRandom {
|
||||||
last: rng.next()
|
last: rng.next()
|
||||||
|
@ -91,7 +91,7 @@ fn make_random_fasta(wr: @io::Writer,
|
||||||
|
|
||||||
fn make_repeat_fasta(wr: @io::Writer, id: ~str, desc: ~str, s: ~str, n: int) {
|
fn make_repeat_fasta(wr: @io::Writer, id: ~str, desc: ~str, s: ~str, n: int) {
|
||||||
unsafe {
|
unsafe {
|
||||||
wr.write_line(~">" + id + ~" " + desc);
|
wr.write_line(~">" + id + " " + desc);
|
||||||
let mut op: ~str = ~"";
|
let mut op: ~str = ~"";
|
||||||
let sl: uint = str::len(s);
|
let sl: uint = str::len(s);
|
||||||
for uint::range(0u, n as uint) |i| {
|
for uint::range(0u, n as uint) |i| {
|
||||||
|
@ -139,13 +139,13 @@ fn main() {
|
||||||
make_cumulative(~[acid('a', 30u32), acid('c', 20u32), acid('g', 20u32),
|
make_cumulative(~[acid('a', 30u32), acid('c', 20u32), acid('g', 20u32),
|
||||||
acid('t', 30u32)]);
|
acid('t', 30u32)]);
|
||||||
let alu: ~str =
|
let alu: ~str =
|
||||||
~"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
|
~"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG\
|
||||||
~"GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
|
GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA\
|
||||||
~"CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
|
CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT\
|
||||||
~"ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
|
ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA\
|
||||||
~"GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
|
GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG\
|
||||||
~"AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
|
AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC\
|
||||||
~"AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
|
AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
|
||||||
make_repeat_fasta(writer, ~"ONE", ~"Homo sapiens alu", alu, n * 2);
|
make_repeat_fasta(writer, ~"ONE", ~"Homo sapiens alu", alu, n * 2);
|
||||||
make_random_fasta(writer, ~"TWO", ~"IUB ambiguity codes", iub, n * 3);
|
make_random_fasta(writer, ~"TWO", ~"IUB ambiguity codes", iub, n * 3);
|
||||||
make_random_fasta(writer, ~"THREE",
|
make_random_fasta(writer, ~"THREE",
|
||||||
|
|
|
@ -103,7 +103,7 @@ pub impl Sudoku {
|
||||||
for u8::range(0u8, 9u8) |row| {
|
for u8::range(0u8, 9u8) |row| {
|
||||||
for u8::range(0u8, 9u8) |col| {
|
for u8::range(0u8, 9u8) |col| {
|
||||||
let color = self.grid[row][col];
|
let color = self.grid[row][col];
|
||||||
if color == 0u8 { work += ~[(row, col)]; }
|
if color == 0u8 { work += [(row, col)]; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
|
||||||
fn_box: || @Cons((), fn_box()),
|
fn_box: || @Cons((), fn_box()),
|
||||||
tuple: (@Cons((), st.tuple.first()),
|
tuple: (@Cons((), st.tuple.first()),
|
||||||
~Cons((), @*st.tuple.second())),
|
~Cons((), @*st.tuple.second())),
|
||||||
vec: st.vec + ~[@Cons((), *st.vec.last())],
|
vec: st.vec + [@Cons((), *st.vec.last())],
|
||||||
res: r(@Cons((), st.res._l))
|
res: r(@Cons((), st.res._l))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl to_str for int {
|
||||||
|
|
||||||
impl<T:to_str> to_str for ~[T] {
|
impl<T:to_str> to_str for ~[T] {
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
~"[" + str::connect(vec::map(*self, |e| e.to_str() ), ~", ") + ~"]"
|
~"[" + str::connect(vec::map(*self, |e| e.to_str() ), ", ") + "]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue