rustc: remove some copies
This commit is contained in:
parent
d60747a248
commit
8f263dd023
@ -65,7 +65,7 @@ struct cache_entry {
|
||||
metas: @~[@ast::meta_item]
|
||||
}
|
||||
|
||||
fn dump_crates(+crate_cache: @mut ~[cache_entry]) {
|
||||
fn dump_crates(crate_cache: @mut ~[cache_entry]) {
|
||||
debug!("resolved crates:");
|
||||
for crate_cache.each |entry| {
|
||||
debug!("cnum: %?", entry.cnum);
|
||||
|
@ -84,11 +84,12 @@ fn libname(cx: Context) -> (~str, ~str) {
|
||||
(str::from_slice(dll_prefix), str::from_slice(dll_suffix))
|
||||
}
|
||||
|
||||
fn find_library_crate_aux(cx: Context,
|
||||
(prefix, suffix): (~str, ~str),
|
||||
filesearch: filesearch::FileSearch) ->
|
||||
Option<(~str, @~[u8])> {
|
||||
let crate_name = crate_name_from_metas(/*bad*/copy cx.metas);
|
||||
fn find_library_crate_aux(
|
||||
cx: Context,
|
||||
(prefix, suffix): (~str, ~str),
|
||||
filesearch: filesearch::FileSearch
|
||||
) -> Option<(~str, @~[u8])> {
|
||||
let crate_name = crate_name_from_metas(cx.metas);
|
||||
let prefix: ~str = prefix + *crate_name + ~"-";
|
||||
let suffix: ~str = /*bad*/copy suffix;
|
||||
|
||||
@ -140,7 +141,7 @@ fn find_library_crate_aux(cx: Context,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn crate_name_from_metas(+metas: &[@ast::meta_item]) -> @~str {
|
||||
pub fn crate_name_from_metas(metas: &[@ast::meta_item]) -> @~str {
|
||||
let name_items = attr::find_meta_items_by_name(metas, ~"name");
|
||||
match vec::last_opt(name_items) {
|
||||
Some(i) => {
|
||||
|
@ -105,7 +105,7 @@ pub fn encode_inlined_item(ecx: @e::EncodeContext,
|
||||
pub fn decode_inlined_item(cdata: @cstore::crate_metadata,
|
||||
tcx: ty::ctxt,
|
||||
maps: Maps,
|
||||
+path: ast_map::path,
|
||||
path: ast_map::path,
|
||||
par_doc: ebml::Doc)
|
||||
-> Option<ast::inlined_item> {
|
||||
let dcx = @DecodeContext {
|
||||
|
@ -71,7 +71,7 @@ pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) {
|
||||
arm.pats);
|
||||
}
|
||||
|
||||
check_arms(cx, (/*bad*/copy *arms));
|
||||
check_arms(cx, *arms);
|
||||
/* Check for exhaustiveness */
|
||||
// Check for empty enum, because is_useful only works on inhabited
|
||||
// types.
|
||||
@ -108,12 +108,12 @@ pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) {
|
||||
}
|
||||
|
||||
// Check for unreachable patterns
|
||||
pub fn check_arms(cx: @MatchCheckCtxt, arms: ~[arm]) {
|
||||
pub fn check_arms(cx: @MatchCheckCtxt, arms: &[arm]) {
|
||||
let mut seen = ~[];
|
||||
for arms.each |arm| {
|
||||
for arm.pats.each |pat| {
|
||||
let v = ~[*pat];
|
||||
match is_useful(cx, copy seen, v) {
|
||||
match is_useful(cx, &seen, v) {
|
||||
not_useful => {
|
||||
cx.tcx.sess.span_err(pat.span, ~"unreachable pattern");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user