Skip to content

Commit 8f263dd

Browse files
committed
rustc: remove some copies
1 parent d60747a commit 8f263dd

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

src/librustc/metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct cache_entry {
6565
metas: @~[@ast::meta_item]
6666
}
6767

68-
fn dump_crates(+crate_cache: @mut ~[cache_entry]) {
68+
fn dump_crates(crate_cache: @mut ~[cache_entry]) {
6969
debug!("resolved crates:");
7070
for crate_cache.each |entry| {
7171
debug!("cnum: %?", entry.cnum);

src/librustc/metadata/loader.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ fn libname(cx: Context) -> (~str, ~str) {
8484
(str::from_slice(dll_prefix), str::from_slice(dll_suffix))
8585
}
8686

87-
fn find_library_crate_aux(cx: Context,
88-
(prefix, suffix): (~str, ~str),
89-
filesearch: filesearch::FileSearch) ->
90-
Option<(~str, @~[u8])> {
91-
let crate_name = crate_name_from_metas(/*bad*/copy cx.metas);
87+
fn find_library_crate_aux(
88+
cx: Context,
89+
(prefix, suffix): (~str, ~str),
90+
filesearch: filesearch::FileSearch
91+
) -> Option<(~str, @~[u8])> {
92+
let crate_name = crate_name_from_metas(cx.metas);
9293
let prefix: ~str = prefix + *crate_name + ~"-";
9394
let suffix: ~str = /*bad*/copy suffix;
9495
@@ -140,7 +141,7 @@ fn find_library_crate_aux(cx: Context,
140141
}
141142
}
142143

143-
pub fn crate_name_from_metas(+metas: &[@ast::meta_item]) -> @~str {
144+
pub fn crate_name_from_metas(metas: &[@ast::meta_item]) -> @~str {
144145
let name_items = attr::find_meta_items_by_name(metas, ~"name");
145146
match vec::last_opt(name_items) {
146147
Some(i) => {

src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub fn encode_inlined_item(ecx: @e::EncodeContext,
105105
pub fn decode_inlined_item(cdata: @cstore::crate_metadata,
106106
tcx: ty::ctxt,
107107
maps: Maps,
108-
+path: ast_map::path,
108+
path: ast_map::path,
109109
par_doc: ebml::Doc)
110110
-> Option<ast::inlined_item> {
111111
let dcx = @DecodeContext {

src/librustc/middle/check_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) {
7171
arm.pats);
7272
}
7373

74-
check_arms(cx, (/*bad*/copy *arms));
74+
check_arms(cx, *arms);
7575
/* Check for exhaustiveness */
7676
// Check for empty enum, because is_useful only works on inhabited
7777
// types.
@@ -108,12 +108,12 @@ pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) {
108108
}
109109

110110
// Check for unreachable patterns
111-
pub fn check_arms(cx: @MatchCheckCtxt, arms: ~[arm]) {
111+
pub fn check_arms(cx: @MatchCheckCtxt, arms: &[arm]) {
112112
let mut seen = ~[];
113113
for arms.each |arm| {
114114
for arm.pats.each |pat| {
115115
let v = ~[*pat];
116-
match is_useful(cx, copy seen, v) {
116+
match is_useful(cx, &seen, v) {
117117
not_useful => {
118118
cx.tcx.sess.span_err(pat.span, ~"unreachable pattern");
119119
}

0 commit comments

Comments
 (0)