Skip to content

Commit cd7f3ad

Browse files
committed
syntax: Removing some bad copies
1 parent 251d0c4 commit cd7f3ad

File tree

4 files changed

+69
-68
lines changed

4 files changed

+69
-68
lines changed

src/libsyntax/ext/fmt.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
6565
// Produces an AST expression that represents a RT::conv record,
6666
// which tells the RT::conv* functions how to perform the conversion
6767

68-
fn make_rt_conv_expr(cx: @ext_ctxt, sp: span, cnv: Conv) -> @ast::expr {
68+
fn make_rt_conv_expr(cx: @ext_ctxt, sp: span, cnv: &Conv) -> @ast::expr {
6969
fn make_flags(cx: @ext_ctxt, sp: span, flags: ~[Flag]) -> @ast::expr {
7070
let mut tmp_expr = make_rt_path_expr(cx, sp, @~"flag_none");
7171
for flags.each |f| {
@@ -139,7 +139,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
139139
make_conv_struct(cx, sp, rt_conv_flags, rt_conv_width,
140140
rt_conv_precision, rt_conv_ty)
141141
}
142-
fn make_conv_call(cx: @ext_ctxt, sp: span, conv_type: ~str, cnv: Conv,
142+
fn make_conv_call(cx: @ext_ctxt, sp: span, conv_type: ~str, cnv: &Conv,
143143
arg: @ast::expr) -> @ast::expr {
144144
let fname = ~"conv_" + conv_type;
145145
let path = make_path_vec(cx, @fname);
@@ -148,11 +148,11 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
148148
return mk_call_global(cx, arg.span, path, args);
149149
}
150150

151-
fn make_new_conv(cx: @ext_ctxt, sp: span, cnv: Conv, arg: @ast::expr) ->
151+
fn make_new_conv(cx: @ext_ctxt, sp: span, cnv: &Conv, arg: @ast::expr) ->
152152
@ast::expr {
153153
// FIXME: Move validation code into core::extfmt (Issue #2249)
154154

155-
fn is_signed_type(cnv: Conv) -> bool {
155+
fn is_signed_type(cnv: &Conv) -> bool {
156156
match cnv.ty {
157157
TyInt(s) => match s {
158158
Signed => return true,
@@ -220,7 +220,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
220220
mk_addr_of(cx, sp, arg))
221221
}
222222
}
223-
fn log_conv(c: Conv) {
223+
fn log_conv(c: &Conv) {
224224
match c.param {
225225
Some(p) => { debug!("param: %s", p.to_str()); }
226226
_ => debug!("param: none")
@@ -285,12 +285,12 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
285285
~"for the given format string");
286286
}
287287
debug!("Building conversion:");
288-
log_conv(/*bad*/ copy *conv);
288+
log_conv(conv);
289289
let arg_expr = args[n];
290290
let c_expr = make_new_conv(
291291
cx,
292292
fmt_sp,
293-
/*bad*/ copy *conv,
293+
conv,
294294
arg_expr
295295
);
296296
piece_exprs.push(c_expr);

src/libsyntax/parse/comments.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
220220
if col < len {
221221
s1 = str::slice(s, col, len);
222222
} else { s1 = ~""; }
223-
} else { s1 = /*bad*/ copy s; }
223+
} else { s1 = s; }
224224
debug!("pushing line: %s", s1);
225225
lines.push(s1);
226226
}
@@ -357,8 +357,8 @@ pub fn gather_comments_and_literals(span_diagnostic:
357357
let TokenAndSpan {tok: tok, sp: sp} = rdr.peek();
358358
if token::is_lit(&tok) {
359359
let s = get_str_from(rdr, bstart);
360-
literals.push(lit {lit: /*bad*/ copy s, pos: sp.lo});
361360
debug!("tok lit: %s", s);
361+
literals.push(lit {lit: s, pos: sp.lo});
362362
} else {
363363
debug!("tok: %s", token::to_str(rdr.interner, &tok));
364364
}

src/libsyntax/parse/parser.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ pub impl Parser {
14381438
let (s, z) = p.parse_sep_and_zerok();
14391439
tt_seq(
14401440
mk_sp(sp.lo ,p.span.hi),
1441-
/*bad*/ copy seq.node,
1441+
seq.node,
14421442
s,
14431443
z
14441444
)
@@ -1855,7 +1855,7 @@ pub impl Parser {
18551855
// Turn on the restriction to stop at | or || so we can parse
18561856
// them as the lambda arguments
18571857
let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP);
1858-
match /*bad*/ copy e.node {
1858+
match e.node {
18591859
expr_call(f, args, NoSugar) => {
18601860
let block = self.parse_lambda_block_expr();
18611861
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
@@ -2129,7 +2129,7 @@ pub impl Parser {
21292129
let lo = self.span.lo;
21302130
let mut hi = self.span.hi;
21312131
let mut pat;
2132-
match copy *self.token {
2132+
match *self.token {
21332133
token::UNDERSCORE => { self.bump(); pat = pat_wild; }
21342134
token::AT => {
21352135
self.bump();
@@ -2237,7 +2237,7 @@ pub impl Parser {
22372237
self.expect(&token::RBRACKET);
22382238
pat = ast::pat_vec(before, slice, after);
22392239
}
2240-
copy tok => {
2240+
tok => {
22412241
if !is_ident_or_path(&tok)
22422242
|| self.is_keyword(&~"true")
22432243
|| self.is_keyword(&~"false")
@@ -3341,6 +3341,7 @@ pub impl Parser {
33413341
VIEW_ITEMS_AND_ITEMS_ALLOWED,
33423342
true);
33433343
let mut items: ~[@item] = starting_items;
3344+
let attrs_remaining_len = attrs_remaining.len();
33443345

33453346
// looks like this code depends on the invariant that
33463347
// outer attributes can't occur on view items (or macros
@@ -3349,7 +3350,7 @@ pub impl Parser {
33493350
while *self.token != term {
33503351
let mut attrs = self.parse_outer_attributes();
33513352
if first {
3352-
attrs = vec::append(/*bad*/ copy attrs_remaining, attrs);
3353+
attrs = attrs_remaining + attrs;
33533354
first = false;
33543355
}
33553356
debug!("parse_mod_items: parse_item_or_view_item(attrs=%?)",
@@ -3378,7 +3379,7 @@ pub impl Parser {
33783379
debug!("parse_mod_items: attrs=%?", attrs);
33793380
}
33803381

3381-
if first && attrs_remaining.len() > 0u {
3382+
if first && attrs_remaining_len > 0u {
33823383
// We parsed attributes for the first item but didn't find it
33833384
self.fatal(~"expected item");
33843385
}

0 commit comments

Comments
 (0)