about summary refs log tree commit diff
path: root/src/test/bench
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-10-14 23:05:01 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-10-19 12:59:40 -0700
commit9d5d97b55d6487ee23b805bc1acbaa0669b82116 (patch)
treeb72dcf7045e331e94ea0f8658d088ab42d917935 /src/test/bench
parentfb169d5543c84e11038ba2d07b538ec88fb49ca6 (diff)
downloadrust-9d5d97b55d6487ee23b805bc1acbaa0669b82116.tar.gz
rust-9d5d97b55d6487ee23b805bc1acbaa0669b82116.zip
Remove a large amount of deprecated functionality
Spring cleaning is here! In the Fall! This commit removes quite a large amount
of deprecated functionality from the standard libraries. I tried to ensure that
only old deprecated functionality was removed.

This is removing lots and lots of deprecated features, so this is a breaking
change. Please consult the deprecation messages of the deleted code to see how
to migrate code forward if it still needs migration.

[breaking-change]
Diffstat (limited to 'src/test/bench')
-rw-r--r--src/test/bench/core-std.rs16
-rw-r--r--src/test/bench/core-uint-to-str.rs2
-rw-r--r--src/test/bench/msgsend-ring-mutex-arcs.rs4
-rw-r--r--src/test/bench/msgsend-ring-rw-arcs.rs4
-rw-r--r--src/test/bench/shootout-ackermann.rs2
-rw-r--r--src/test/bench/shootout-fibo.rs2
-rw-r--r--src/test/bench/shootout-k-nucleotide-pipes.rs29
-rw-r--r--src/test/bench/shootout-nbody.rs20
-rw-r--r--src/test/bench/shootout-pfib.rs2
-rw-r--r--src/test/bench/std-smallintmap.rs6
-rw-r--r--src/test/bench/sudoku.rs36
-rw-r--r--src/test/bench/task-perf-alloc-unwind.rs27
-rw-r--r--src/test/bench/task-perf-jargon-metal-smoke.rs2
-rw-r--r--src/test/bench/task-perf-spawnalot.rs2
14 files changed, 86 insertions, 68 deletions
diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs
index 9af3c0c6c8c..404e2e31b05 100644
--- a/src/test/bench/core-std.rs
+++ b/src/test/bench/core-std.rs
@@ -68,7 +68,7 @@ fn shift_push() {
     let mut v2 = Vec::new();
 
     while v1.len() > 0 {
-        v2.push(v1.shift().unwrap());
+        v2.push(v1.remove(0).unwrap());
     }
 }
 
@@ -93,9 +93,11 @@ fn vec_plus() {
     while i < 1500 {
         let rv = Vec::from_elem(r.gen_range(0u, i + 1), i);
         if r.gen() {
-            v.push_all_move(rv);
+            v.extend(rv.into_iter());
         } else {
-            v = rv.clone().append(v.as_slice());
+            let mut rv = rv.clone();
+            rv.push_all(v.as_slice());
+            v = rv;
         }
         i += 1;
     }
@@ -109,10 +111,14 @@ fn vec_append() {
     while i < 1500 {
         let rv = Vec::from_elem(r.gen_range(0u, i + 1), i);
         if r.gen() {
-            v = v.clone().append(rv.as_slice());
+            let mut t = v.clone();
+            t.push_all(rv.as_slice());
+            v = t;
         }
         else {
-            v = rv.clone().append(v.as_slice());
+            let mut t = rv.clone();
+            t.push_all(v.as_slice());
+            v = t;
         }
         i += 1;
     }
diff --git a/src/test/bench/core-uint-to-str.rs b/src/test/bench/core-uint-to-str.rs
index 1f527e89eb2..98113cb8347 100644
--- a/src/test/bench/core-uint-to-str.rs
+++ b/src/test/bench/core-uint-to-str.rs
@@ -21,7 +21,7 @@ fn main() {
         args.into_iter().collect()
     };
 
-    let n = from_str::<uint>(args.get(1).as_slice()).unwrap();
+    let n = from_str::<uint>(args[1].as_slice()).unwrap();
 
     for i in range(0u, n) {
         let x = i.to_string();
diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs
index d1a2dcf6d55..1a9ffd68284 100644
--- a/src/test/bench/msgsend-ring-mutex-arcs.rs
+++ b/src/test/bench/msgsend-ring-mutex-arcs.rs
@@ -72,8 +72,8 @@ fn main() {
         args.clone().into_iter().collect()
     };
 
-    let num_tasks = from_str::<uint>(args.get(1).as_slice()).unwrap();
-    let msg_per_task = from_str::<uint>(args.get(2).as_slice()).unwrap();
+    let num_tasks = from_str::<uint>(args[1].as_slice()).unwrap();
+    let msg_per_task = from_str::<uint>(args[2].as_slice()).unwrap();
 
     let (mut num_chan, num_port) = init();
 
diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs
index c07656a5e4b..5e192a14793 100644
--- a/src/test/bench/msgsend-ring-rw-arcs.rs
+++ b/src/test/bench/msgsend-ring-rw-arcs.rs
@@ -72,8 +72,8 @@ fn main() {
         args.clone().into_iter().collect()
     };
 
-    let num_tasks = from_str::<uint>(args.get(1).as_slice()).unwrap();
-    let msg_per_task = from_str::<uint>(args.get(2).as_slice()).unwrap();
+    let num_tasks = from_str::<uint>(args[1].as_slice()).unwrap();
+    let msg_per_task = from_str::<uint>(args[2].as_slice()).unwrap();
 
     let (mut num_chan, num_port) = init();
 
diff --git a/src/test/bench/shootout-ackermann.rs b/src/test/bench/shootout-ackermann.rs
index 90d2c857858..e7a50382c94 100644
--- a/src/test/bench/shootout-ackermann.rs
+++ b/src/test/bench/shootout-ackermann.rs
@@ -31,6 +31,6 @@ fn main() {
     } else {
         args.into_iter().collect()
     };
-    let n = from_str::<int>(args.get(1).as_slice()).unwrap();
+    let n = from_str::<int>(args[1].as_slice()).unwrap();
     println!("Ack(3,{}): {}\n", n, ack(3, n));
 }
diff --git a/src/test/bench/shootout-fibo.rs b/src/test/bench/shootout-fibo.rs
index 1f42cc6e00c..10c0d0a8044 100644
--- a/src/test/bench/shootout-fibo.rs
+++ b/src/test/bench/shootout-fibo.rs
@@ -27,6 +27,6 @@ fn main() {
     } else {
         args.into_iter().collect()
     };
-    let n = from_str::<int>(args.get(1).as_slice()).unwrap();
+    let n = from_str::<int>(args[1].as_slice()).unwrap();
     println!("{}\n", fib(n));
 }
diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs
index 1754df9bf44..5d77e27f948 100644
--- a/src/test/bench/shootout-k-nucleotide-pipes.rs
+++ b/src/test/bench/shootout-k-nucleotide-pipes.rs
@@ -83,7 +83,7 @@ fn find(mm: &HashMap<Vec<u8> , uint>, key: String) -> uint {
 
 // given a map, increment the counter for a key
 fn update_freq(mm: &mut HashMap<Vec<u8> , uint>, key: &[u8]) {
-    let key = Vec::from_slice(key);
+    let key = key.to_vec();
     let newval = match mm.pop(&key) {
         Some(v) => v + 1,
         None => 1
@@ -103,7 +103,7 @@ fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> Vec<u8> {
       ii += 1u;
    }
 
-   return Vec::from_slice(bb[len - (nn - 1u)..len]);
+   return bb[len - (nn - 1u)..len].to_vec();
 }
 
 fn make_sequence_processor(sz: uint,
@@ -117,15 +117,14 @@ fn make_sequence_processor(sz: uint,
 
    loop {
 
-      line = from_parent.recv();
-      if line == Vec::new() { break; }
+       line = from_parent.recv();
+       if line == Vec::new() { break; }
 
-       carry = windows_with_carry(carry.append(line.as_slice()).as_slice(),
-                                  sz,
-                                  |window| {
-         update_freq(&mut freqs, window);
-         total += 1u;
-      });
+       carry.push_all(line.as_slice());
+       carry = windows_with_carry(carry.as_slice(), sz, |window| {
+           update_freq(&mut freqs, window);
+           total += 1u;
+       });
    }
 
    let buffer = match sz {
@@ -149,7 +148,7 @@ fn main() {
 
     let rdr = if os::getenv("RUST_BENCH").is_some() {
         let foo = include_bin!("shootout-k-nucleotide.data");
-        box MemReader::new(Vec::from_slice(foo)) as Box<Reader>
+        box MemReader::new(foo.to_vec()) as Box<Reader>
     } else {
         box stdio::stdin() as Box<Reader>
     };
@@ -203,8 +202,8 @@ fn main() {
                let line_bytes = line.as_bytes();
 
                for (ii, _sz) in sizes.iter().enumerate() {
-                   let lb = Vec::from_slice(line_bytes);
-                   to_child.get(ii).send(lb);
+                   let lb = line_bytes.to_vec();
+                   to_child[ii].send(lb);
                }
            }
 
@@ -215,11 +214,11 @@ fn main() {
 
    // finish...
    for (ii, _sz) in sizes.iter().enumerate() {
-       to_child.get(ii).send(Vec::new());
+       to_child[ii].send(Vec::new());
    }
 
    // now fetch and print result messages
    for (ii, _sz) in sizes.iter().enumerate() {
-       println!("{}", from_child.get(ii).recv());
+       println!("{}", from_child[ii].recv());
    }
 }
diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs
index 3c8e8389564..8486fa5b034 100644
--- a/src/test/bench/shootout-nbody.rs
+++ b/src/test/bench/shootout-nbody.rs
@@ -102,7 +102,7 @@ fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: int) {
     for _ in range(0, steps) {
         let mut b_slice = bodies.as_mut_slice();
         loop {
-            let bi = match b_slice.mut_shift_ref() {
+            let bi = match shift_mut_ref(&mut b_slice) {
                 Some(bi) => bi,
                 None => break
             };
@@ -183,3 +183,21 @@ fn main() {
 
     println!("{:.9f}", energy(&bodies));
 }
+
+/// Pop a mutable reference off the head of a slice, mutating the slice to no
+/// longer contain the mutable reference. This is a safe operation because the
+/// two mutable borrows are entirely disjoint.
+fn shift_mut_ref<'a, T>(r: &mut &'a mut [T]) -> Option<&'a mut T> {
+    use std::mem;
+    use std::raw::Repr;
+
+    if r.len() == 0 { return None }
+    unsafe {
+        let mut raw = r.repr();
+        let ret = raw.data as *mut T;
+        raw.data = raw.data.offset(1);
+        raw.len -= 1;
+        *r = mem::transmute(raw);
+        Some(unsafe { &mut *ret })
+    }
+}
diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs
index 516bd99ab55..91b9e058e8f 100644
--- a/src/test/bench/shootout-pfib.rs
+++ b/src/test/bench/shootout-pfib.rs
@@ -102,7 +102,7 @@ fn main() {
     if opts.stress {
         stress(2);
     } else {
-        let max = uint::parse_bytes(args.get(1).as_bytes(), 10u).unwrap() as
+        let max = uint::parse_bytes(args[1].as_bytes(), 10u).unwrap() as
             int;
 
         let num_trials = 10;
diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs
index c495e597ca6..2086980b016 100644
--- a/src/test/bench/std-smallintmap.rs
+++ b/src/test/bench/std-smallintmap.rs
@@ -25,7 +25,7 @@ fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap<uint>) {
 
 fn check_sequential(min: uint, max: uint, map: &SmallIntMap<uint>) {
     for i in range(min, max) {
-        assert_eq!(*map.get(&i), i + 22u);
+        assert_eq!(map[i], i + 22u);
     }
 }
 
@@ -38,8 +38,8 @@ fn main() {
     } else {
         args.into_iter().collect()
     };
-    let max = from_str::<uint>(args.get(1).as_slice()).unwrap();
-    let rep = from_str::<uint>(args.get(2).as_slice()).unwrap();
+    let max = from_str::<uint>(args[1].as_slice()).unwrap();
+    let rep = from_str::<uint>(args[2].as_slice()).unwrap();
 
     let mut checkf = 0.0;
     let mut appendf = 0.0;
diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs
index 728f6bd043a..01c412c6d31 100644
--- a/src/test/bench/sudoku.rs
+++ b/src/test/bench/sudoku.rs
@@ -55,8 +55,8 @@ impl Sudoku {
     pub fn equal(&self, other: &Sudoku) -> bool {
         for row in range(0u8, 9u8) {
             for col in range(0u8, 9u8) {
-                if *self.grid.get(row as uint).get(col as uint) !=
-                        *other.grid.get(row as uint).get(col as uint) {
+                if self.grid[row as uint][col as uint] !=
+                        other.grid[row as uint][col as uint] {
                     return false;
                 }
             }
@@ -77,10 +77,10 @@ impl Sudoku {
                                        .collect();
 
             if comps.len() == 3u {
-                let row     = from_str::<uint>(*comps.get(0)).unwrap() as u8;
-                let col     = from_str::<uint>(*comps.get(1)).unwrap() as u8;
+                let row     = from_str::<uint>(comps[0]).unwrap() as u8;
+                let col     = from_str::<uint>(comps[1]).unwrap() as u8;
                 *g.get_mut(row as uint).get_mut(col as uint) =
-                    from_str::<uint>(*comps.get(2)).unwrap() as u8;
+                    from_str::<uint>(comps[2]).unwrap() as u8;
             }
             else {
                 fail!("Invalid sudoku file");
@@ -91,11 +91,9 @@ impl Sudoku {
 
     pub fn write(&self, writer: &mut io::Writer) {
         for row in range(0u8, 9u8) {
-            write!(writer, "{}", *self.grid.get(row as uint).get(0));
+            write!(writer, "{}", self.grid[row as uint][0]);
             for col in range(1u8, 9u8) {
-                write!(writer, " {}", *self.grid
-                                           .get(row as uint)
-                                           .get(col as uint));
+                write!(writer, " {}", self.grid[row as uint][col as uint]);
             }
             write!(writer, "\n");
          }
@@ -106,7 +104,7 @@ impl Sudoku {
         let mut work: Vec<(u8, u8)> = Vec::new(); /* queue of uncolored fields */
         for row in range(0u8, 9u8) {
             for col in range(0u8, 9u8) {
-                let color = *self.grid.get(row as uint).get(col as uint);
+                let color = self.grid[row as uint][col as uint];
                 if color == 0u8 {
                     work.push((row, col));
                 }
@@ -116,9 +114,9 @@ impl Sudoku {
         let mut ptr = 0u;
         let end = work.len();
         while ptr < end {
-            let (row, col) = *work.get(ptr);
+            let (row, col) = work[ptr];
             // is there another color to try?
-            let the_color = *self.grid.get(row as uint).get(col as uint) +
+            let the_color = self.grid[row as uint][col as uint] +
                                 (1 as u8);
             if self.next_color(row, col, the_color) {
                 //  yes: advance work list
@@ -151,12 +149,10 @@ impl Sudoku {
     // find colors available in neighbourhood of (row, col)
     fn drop_colors(&mut self, avail: &mut Colors, row: u8, col: u8) {
         for idx in range(0u8, 9u8) {
-            avail.remove(*self.grid
-                              .get(idx as uint)
-                              .get(col as uint)); /* check same column fields */
-            avail.remove(*self.grid
-                              .get(row as uint)
-                              .get(idx as uint)); /* check same row fields */
+            /* check same column fields */
+            avail.remove(self.grid[idx as uint][col as uint]);
+            /* check same row fields */
+            avail.remove(self.grid[row as uint][idx as uint]);
         }
 
         // check same block fields
@@ -164,9 +160,7 @@ impl Sudoku {
         let col0 = (col / 3u8) * 3u8;
         for alt_row in range(row0, row0 + 3u8) {
             for alt_col in range(col0, col0 + 3u8) {
-                avail.remove(*self.grid
-                                  .get(alt_row as uint)
-                                  .get(alt_col as uint));
+                avail.remove(self.grid[alt_row as uint][alt_col as uint]);
             }
         }
     }
diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs
index a86b797544a..bdeee5fb6e0 100644
--- a/src/test/bench/task-perf-alloc-unwind.rs
+++ b/src/test/bench/task-perf-alloc-unwind.rs
@@ -78,21 +78,22 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
         let depth = depth - 1;
 
         let st = match st {
-          None => {
-            State {
-                unique: box Nil,
-                vec: vec!(box Nil),
-                res: r(box Nil)
+            None => {
+                State {
+                    unique: box Nil,
+                    vec: vec!(box Nil),
+                    res: r(box Nil)
+                }
             }
-          }
-          Some(st) => {
-            State {
-                unique: box Cons((), box *st.unique),
-                vec: st.vec.clone().append(
-                        &[box Cons((), st.vec.last().unwrap().clone())]),
-                res: r(box Cons((), st.res._l.clone()))
+            Some(st) => {
+                let mut v = st.vec.clone();
+                v.push_all(&[box Cons((), st.vec.last().unwrap().clone())]);
+                State {
+                    unique: box Cons((), box *st.unique),
+                    vec: v,
+                    res: r(box Cons((), st.res._l.clone())),
+                }
             }
-          }
         };
 
         recurse_or_fail(depth, Some(st));
diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs
index 17e1ad423f9..9ebdbf0682d 100644
--- a/src/test/bench/task-perf-jargon-metal-smoke.rs
+++ b/src/test/bench/task-perf-jargon-metal-smoke.rs
@@ -49,7 +49,7 @@ fn main() {
     };
 
     let (tx, rx) = channel();
-    child_generation(from_str::<uint>(args.get(1).as_slice()).unwrap(), tx);
+    child_generation(from_str::<uint>(args[1].as_slice()).unwrap(), tx);
     if rx.recv_opt().is_err() {
         fail!("it happened when we slumbered");
     }
diff --git a/src/test/bench/task-perf-spawnalot.rs b/src/test/bench/task-perf-spawnalot.rs
index a871ac989f3..533005b1fb3 100644
--- a/src/test/bench/task-perf-spawnalot.rs
+++ b/src/test/bench/task-perf-spawnalot.rs
@@ -31,7 +31,7 @@ fn main() {
     } else {
         args.into_iter().collect()
     };
-    let n = from_str::<uint>(args.get(1).as_slice()).unwrap();
+    let n = from_str::<uint>(args[1].as_slice()).unwrap();
     let mut i = 0u;
     while i < n { task::spawn(proc() f(n) ); i += 1u; }
 }