Skip to content

Commit 1ec06e0

Browse files
alexcrichtonthestinger
authored andcommitted
Remove the global 'vec::to_owned' function
1 parent 2b96408 commit 1ec06e0

File tree

19 files changed

+31
-48
lines changed

19 files changed

+31
-48
lines changed

src/libextra/flatpipes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ pub mod flatteners {
446446
T: Decodable<D>>(
447447
buf: &[u8])
448448
-> T {
449-
let buf = vec::to_owned(buf);
449+
let buf = buf.to_owned();
450450
let buf_reader = @BufReader::new(buf);
451451
let reader = buf_reader as @Reader;
452452
let mut deser: D = FromReader::from_reader(reader);

src/libextra/getopts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
343343
}
344344
i += 1;
345345
}
346-
return Ok(Matches {opts: vec::to_owned(opts),
346+
return Ok(Matches {opts: opts.to_owned(),
347347
vals: vals,
348348
free: free});
349349
}

src/libextra/md4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn md4(msg: &[u8]) -> Quad {
2828
let orig_len: u64 = (msg.len() * 8u) as u64;
2929

3030
// pad message
31-
let mut msg = vec::append(vec::to_owned(msg), [0x80u8]);
31+
let mut msg = vec::append(msg.to_owned(), [0x80u8]);
3232
let mut bitlen = orig_len + 8u64;
3333
while (bitlen + 64u64) % 512u64 > 0u64 {
3434
msg.push(0u8);

src/libextra/num/bigint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ impl BigUint {
567567
/// Creates and initializes an BigUint.
568568
569569
pub fn from_slice(slice: &[BigDigit]) -> BigUint {
570-
return BigUint::new(vec::to_owned(slice));
570+
return BigUint::new(slice.to_owned());
571571
}
572572

573573
/// Creates and initializes an BigUint.

src/libextra/stats.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use sort;
1212
use std::cmp;
1313
use std::io;
1414
use std::num;
15-
use std::vec;
1615

1716
// NB: this can probably be rewritten in terms of num::Num
1817
// to be less f64-specific.
@@ -200,13 +199,13 @@ impl<'self> Stats for &'self [f64] {
200199
}
201200

202201
fn percentile(self, pct: f64) -> f64 {
203-
let mut tmp = vec::to_owned(self);
202+
let mut tmp = self.to_owned();
204203
sort::tim_sort(tmp);
205204
percentile_of_sorted(tmp, pct)
206205
}
207206

208207
fn quartiles(self) -> (f64,f64,f64) {
209-
let mut tmp = vec::to_owned(self);
208+
let mut tmp = self.to_owned();
210209
sort::tim_sort(tmp);
211210
let a = percentile_of_sorted(tmp, 25.0);
212211
let b = percentile_of_sorted(tmp, 50.0);
@@ -251,7 +250,7 @@ priv fn percentile_of_sorted(sorted_samples: &[f64],
251250
///
252251
/// See: http://en.wikipedia.org/wiki/Winsorising
253252
pub fn winsorize(samples: &mut [f64], pct: f64) {
254-
let mut tmp = vec::to_owned(samples);
253+
let mut tmp = samples.to_owned();
255254
sort::tim_sort(tmp);
256255
let lo = percentile_of_sorted(tmp, pct);
257256
let hi = percentile_of_sorted(tmp, 100.0-pct);

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ pub fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt,
714714
let item_doc = lookup_item(id, cdata.data);
715715
let path = {
716716
let item_path = item_path(item_doc);
717-
vec::to_owned(item_path.init())
717+
item_path.init().to_owned()
718718
};
719719
match decode_inlined_item(cdata, tcx, copy path, item_doc) {
720720
Some(ref ii) => csearch::found((/*bad*/copy *ii)),

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
16591659

16601660
let writer_bytes: &mut ~[u8] = wr.bytes;
16611661

1662-
vec::to_owned(metadata_encoding_version) +
1662+
metadata_encoding_version.to_owned() +
16631663
flate::deflate_bytes(*writer_bytes)
16641664
}
16651665

src/librustc/middle/check_match.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
484484
match cx.tcx.def_map.find(&pat_id) {
485485
Some(&def_variant(_, id)) => {
486486
if variant(id) == *ctor_id {
487-
Some(vec::to_owned(r.tail()))
487+
Some(r.tail().to_owned())
488488
} else {
489489
None
490490
}
@@ -522,7 +522,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
522522
_ => fail!("type error")
523523
};
524524
if match_ {
525-
Some(vec::to_owned(r.tail()))
525+
Some(r.tail().to_owned())
526526
} else {
527527
None
528528
}
@@ -569,7 +569,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
569569
_ => fail!("type error")
570570
};
571571
if match_ {
572-
Some(vec::to_owned(r.tail()))
572+
Some(r.tail().to_owned())
573573
} else {
574574
None
575575
}
@@ -579,7 +579,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
579579
Some(args) => args,
580580
None => vec::from_elem(arity, wild())
581581
};
582-
Some(vec::append(args, vec::to_owned(r.tail())))
582+
Some(vec::append(args, r.tail()))
583583
}
584584
def_variant(_, _) => None,
585585

@@ -591,7 +591,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
591591
Some(args) => new_args = args,
592592
None => new_args = vec::from_elem(arity, wild())
593593
}
594-
Some(vec::append(new_args, vec::to_owned(r.tail())))
594+
Some(vec::append(new_args, r.tail()))
595595
}
596596
_ => None
597597
}
@@ -609,7 +609,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
609609
_ => wild()
610610
}
611611
});
612-
Some(vec::append(args, vec::to_owned(r.tail())))
612+
Some(vec::append(args, r.tail()))
613613
} else {
614614
None
615615
}
@@ -640,7 +640,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
640640
_ => wild()
641641
}
642642
}).collect();
643-
Some(vec::append(args, vec::to_owned(r.tail())))
643+
Some(vec::append(args, r.tail()))
644644
}
645645
}
646646
}
@@ -676,14 +676,14 @@ pub fn specialize(cx: &MatchCheckCtxt,
676676
single => true,
677677
_ => fail!("type error")
678678
};
679-
if match_ { Some(vec::to_owned(r.tail())) } else { None }
679+
if match_ { Some(r.tail().to_owned()) } else { None }
680680
}
681681
pat_range(lo, hi) => {
682682
let (c_lo, c_hi) = match *ctor_id {
683683
val(ref v) => ((/*bad*/copy *v), (/*bad*/copy *v)),
684684
range(ref lo, ref hi) =>
685685
((/*bad*/copy *lo), (/*bad*/copy *hi)),
686-
single => return Some(vec::to_owned(r.tail())),
686+
single => return Some(r.tail().to_owned()),
687687
_ => fail!("type error")
688688
};
689689
let v_lo = eval_const_expr(cx.tcx, lo);
@@ -693,7 +693,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
693693
let m2 = compare_const_vals(&c_hi, &v_hi);
694694
match (m1, m2) {
695695
(Some(val1), Some(val2)) if val1 >= 0 && val2 <= 0 => {
696-
Some(vec::to_owned(r.tail()))
696+
Some(r.tail().to_owned())
697697
},
698698
(Some(_), Some(_)) => None,
699699
_ => {
@@ -734,7 +734,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
734734
}
735735

736736
pub fn default(cx: &MatchCheckCtxt, r: &[@pat]) -> Option<~[@pat]> {
737-
if is_wild(cx, r[0]) { Some(vec::to_owned(r.tail())) }
737+
if is_wild(cx, r[0]) { Some(r.tail().to_owned()) }
738738
else { None }
739739
}
740740

src/librustc/middle/trans/adt.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
use std::container::Map;
4848
use std::libc::c_ulonglong;
4949
use std::option::{Option, Some, None};
50-
use std::vec;
5150

5251
use lib::llvm::{ValueRef, True, IntEQ, IntNE};
5352
use middle::trans::_match;
@@ -219,7 +218,7 @@ fn mk_struct(cx: &mut CrateContext, tys: &[ty::t], packed: bool) -> Struct {
219218
size: machine::llsize_of_alloc(cx, llty_rec) /*bad*/as u64,
220219
align: machine::llalign_of_min(cx, llty_rec) /*bad*/as u64,
221220
packed: packed,
222-
fields: vec::to_owned(tys)
221+
fields: tys.to_owned(),
223222
}
224223
}
225224

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3782,7 +3782,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
37823782
}
37833783

37843784
ast_map::node_variant(ref variant, _, path) => {
3785-
vec::append_one(vec::to_owned(path.init()),
3785+
vec::append_one(path.init().to_owned(),
37863786
ast_map::path_name((*variant).node.name))
37873787
}
37883788

src/libstd/rand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ impl<R: Rng> RngUtil for R {
591591

592592
/// Shuffle a vec
593593
fn shuffle<T:Copy>(&mut self, values: &[T]) -> ~[T] {
594-
let mut m = vec::to_owned(values);
594+
let mut m = values.to_owned();
595595
self.shuffle_mut(m);
596596
m
597597
}

src/libstd/vec.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[T] {
9191
}
9292
}
9393

94-
/// Creates a new unique vector with the same contents as the slice
95-
pub fn to_owned<T:Copy>(t: &[T]) -> ~[T] {
96-
from_fn(t.len(), |i| copy t[i])
97-
}
98-
9994
/// Creates a new vector with a capacity of `capacity`
10095
#[cfg(stage0)]
10196
pub fn with_capacity<T>(capacity: uint) -> ~[T] {

src/libsyntax/attr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use diagnostic::span_handler;
2020
use parse::comments::{doc_comment_style, strip_doc_comment_decoration};
2121

2222
use std::hashmap::HashSet;
23-
use std::vec;
2423
/* Constructors */
2524

2625
pub fn mk_name_value_item_str(name: @str, value: @str)
@@ -256,7 +255,7 @@ pub fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: &str)
256255

257256
pub fn sort_meta_items(items: &[@ast::meta_item]) -> ~[@ast::meta_item] {
258257
// This is sort of stupid here, converting to a vec of mutables and back
259-
let mut v = vec::to_owned(items);
258+
let mut v = items.to_owned();
260259
do extra::sort::quick_sort(v) |ma, mb| {
261260
get_meta_item_name(*ma) <= get_meta_item_name(*mb)
262261
}

src/libsyntax/ext/asm.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use ext::base::*;
1919
use parse;
2020
use parse::token;
2121

22-
use std::vec;
23-
2422
enum State {
2523
Asm,
2624
Outputs,
@@ -43,7 +41,7 @@ pub fn expand_asm(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
4341
-> base::MacResult {
4442
let p = parse::new_parser_from_tts(cx.parse_sess(),
4543
cx.cfg(),
46-
vec::to_owned(tts));
44+
tts.to_owned());
4745

4846
let mut asm = @"";
4947
let mut outputs = ~[];

src/libsyntax/ext/base.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use parse;
1818
use parse::token;
1919
use parse::token::{ident_to_str, intern, str_to_ident};
2020

21-
use std::vec;
2221
use std::hashmap::HashMap;
2322

2423
// new-style macro! tt code:
@@ -362,7 +361,7 @@ pub fn get_exprs_from_tts(cx: @ExtCtxt, tts: &[ast::token_tree])
362361
-> ~[@ast::expr] {
363362
let p = parse::new_parser_from_tts(cx.parse_sess(),
364363
cx.cfg(),
365-
vec::to_owned(tts));
364+
tts.to_owned());
366365
let mut es = ~[];
367366
while *p.token != token::EOF {
368367
if es.len() != 0 {

src/libsyntax/ext/log_syntax.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use ext::base;
1515
use print;
1616
use parse::token::{get_ident_interner};
1717

18-
use std::vec;
1918
use std::io;
2019

2120
pub fn expand_syntax_ext(cx: @ExtCtxt,
@@ -26,7 +25,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt,
2625
cx.print_backtrace();
2726
io::stdout().write_line(
2827
print::pprust::tt_to_str(
29-
&ast::tt_delim(vec::to_owned(tt)),
28+
&ast::tt_delim(tt.to_owned()),
3029
get_ident_interner()));
3130

3231
//trivial expression

src/libsyntax/ext/quote.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ use parse::token::*;
1717
use parse::token;
1818
use parse;
1919

20-
use std::vec;
21-
2220
/**
2321
*
2422
* Quasiquoting works via token trees.
@@ -653,7 +651,7 @@ fn expand_tts(cx: @ExtCtxt,
653651
let p = parse::new_parser_from_tts(
654652
cx.parse_sess(),
655653
cx.cfg(),
656-
vec::to_owned(tts)
654+
tts.to_owned()
657655
);
658656
*p.quote_depth += 1u;
659657
let tts = p.parse_all_token_trees();

src/libsyntax/ext/trace_macros.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ use parse::lexer::{new_tt_reader, reader};
1616
use parse::parser::Parser;
1717
use parse::token::keywords;
1818

19-
use std::vec;
20-
2119
pub fn expand_trace_macros(cx: @ExtCtxt,
2220
sp: span,
2321
tt: &[ast::token_tree])
@@ -27,7 +25,7 @@ pub fn expand_trace_macros(cx: @ExtCtxt,
2725
let tt_rdr = new_tt_reader(
2826
copy cx.parse_sess().span_diagnostic,
2927
None,
30-
vec::to_owned(tt)
28+
tt.to_owned()
3129
);
3230
let rdr = tt_rdr as @reader;
3331
let rust_parser = Parser(

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use parse::token::{get_ident_interner, special_idents, gensym_ident, ident_to_st
2323
use parse::token::{FAT_ARROW, SEMI, nt_matchers, nt_tt};
2424
use print;
2525

26-
use std::vec;
2726
use std::io;
2827

2928
pub fn add_new_extension(cx: @ExtCtxt,
@@ -82,7 +81,7 @@ pub fn add_new_extension(cx: @ExtCtxt,
8281
io::println(fmt!("%s! { %s }",
8382
cx.str_of(name),
8483
print::pprust::tt_to_str(
85-
&ast::tt_delim(vec::to_owned(arg)),
84+
&ast::tt_delim(arg.to_owned()),
8685
get_ident_interner())));
8786
}
8887

@@ -99,7 +98,7 @@ pub fn add_new_extension(cx: @ExtCtxt,
9998
let arg_rdr = new_tt_reader(
10099
s_d,
101100
None,
102-
vec::to_owned(arg)
101+
arg.to_owned()
103102
) as @reader;
104103
match parse(cx.parse_sess(), cx.cfg(), arg_rdr, *mtcs) {
105104
success(named_matches) => {

0 commit comments

Comments
 (0)