auto merge of #7430 : huonw/rust/vec-kill, r=thestinger

This commit is contained in:
bors 2013-06-27 15:01:58 -07:00
commit 63afb8ccc8
51 changed files with 546 additions and 719 deletions

View file

@ -29,7 +29,7 @@ macro_rules! bench (
fn main() {
let argv = os::args();
let tests = vec::slice(argv, 1, argv.len());
let tests = argv.slice(1, argv.len());
bench!(shift_push);
bench!(read_line);

View file

@ -96,7 +96,7 @@ impl RepeatFasta {
copy_memory(buf, alu, alu_len);
let buf_len = buf.len();
copy_memory(vec::mut_slice(buf, alu_len, buf_len),
copy_memory(buf.mut_slice(alu_len, buf_len),
alu,
LINE_LEN);

View file

@ -90,7 +90,7 @@ fn find(mm: &HashMap<~[u8], uint>, key: ~str) -> uint {
// given a map, increment the counter for a key
fn update_freq(mm: &mut HashMap<~[u8], uint>, key: &[u8]) {
let key = vec::slice(key, 0, key.len()).to_owned();
let key = key.to_owned();
let newval = match mm.pop(&key) {
Some(v) => v + 1,
None => 1
@ -107,11 +107,11 @@ fn windows_with_carry(bb: &[u8], nn: uint,
let len = bb.len();
while ii < len - (nn - 1u) {
it(vec::slice(bb, ii, ii+nn));
it(bb.slice(ii, ii+nn));
ii += 1u;
}
return vec::slice(bb, len - (nn - 1u), len).to_owned();
return bb.slice(len - (nn - 1u), len).to_owned();
}
fn make_sequence_processor(sz: uint,

View file

@ -8,7 +8,7 @@ use std::libc::{STDIN_FILENO, c_int, fdopen, fgets, fileno, fopen, fstat};
use std::libc::{stat, strlen};
use std::ptr::null;
use std::unstable::intrinsics::init;
use std::vec::{reverse, slice};
use std::vec::{reverse};
use extra::sort::quick_sort3;
static LINE_LEN: uint = 80;
@ -194,7 +194,7 @@ fn unpack_symbol(c: u8) -> u8 {
fn next_char<'a>(mut buf: &'a [u8]) -> &'a [u8] {
loop {
buf = slice(buf, 1, buf.len());
buf = buf.slice(1, buf.len());
if buf.len() == 0 {
break;
}
@ -226,7 +226,7 @@ fn read_stdin() -> ~[u8] {
fgets(transmute(&mut window[0]), LINE_LEN as c_int, stdin);
{
if vec::slice(window, 0, 6) == header {
if window.slice(0, 6) == header {
break;
}
}
@ -235,9 +235,7 @@ fn read_stdin() -> ~[u8] {
while fgets(transmute(&mut window[0]),
LINE_LEN as c_int,
stdin) != null() {
window = vec::mut_slice(window,
strlen(transmute(&window[0])) as uint,
window.len());
window = window.mut_slice(strlen(transmute(&window[0])) as uint, window.len());
}
}

View file

@ -32,7 +32,6 @@ use std::str;
use std::task;
use std::u64;
use std::uint;
use std::vec;
fn fib(n: int) -> int {
fn pfib(c: &Chan<int>, n: int) {
@ -62,7 +61,7 @@ struct Config {
fn parse_opts(argv: ~[~str]) -> Config {
let opts = ~[getopts::optflag(~"stress")];
let opt_args = vec::slice(argv, 1, argv.len());
let opt_args = argv.slice(1, argv.len());
match getopts::getopts(opt_args, opts) {
Ok(ref m) => {

View file

@ -5,7 +5,6 @@ use std::cast::transmute;
use std::libc::{STDOUT_FILENO, c_int, fdopen, fgets, fopen, fputc, fwrite};
use std::libc::{size_t};
use std::ptr::null;
use std::vec::{capacity, reserve, reserve_at_least};
use std::vec::raw::set_len;
static LINE_LEN: u32 = 80;
@ -103,13 +102,13 @@ fn main() {
let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0]));
let mut out: ~[u8] = ~[];
reserve(&mut out, 12777888);
out.reserve(12777888);
let mut pos = 0;
loop {
let needed = pos + (LINE_LEN as uint) + 1;
if capacity(&out) < needed {
reserve_at_least(&mut out, needed);
if out.capacity() < needed {
out.reserve_at_least(needed);
}
let mut ptr = out.unsafe_mut_ref(pos);

View file

@ -8,12 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::vec;
fn vec_peek<'r, T>(v: &'r [T]) -> &'r [T] {
// This doesn't work, and should.
// v.slice(1, 5)
vec::slice(v, 1, 5)
v.slice(1, 5)
}
pub fn main() {}

View file

@ -8,11 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::vec;
pub fn main() {
let v = ~[1,2,3,4,5];
let v2 = vec::slice(v, 1, 3);
let v2 = v.slice(1, 3);
assert_eq!(v2[0], 2);
assert_eq!(v2[1], 3);
}