use std::rt::global_heap;
use std::intrinsics::{TyDesc, get_tydesc};
use std::intrinsics;
-use std::slice;
// The way arena uses arrays is really deeply awful. The arrays are
// allocated, and have capacities reserved, but the fill for the array
// will always stay at 0.
#[deriving(Clone, Eq)]
struct Chunk {
- data: Rc<RefCell<~[u8]>>,
+ data: Rc<RefCell<Vec<u8> >>,
fill: Cell<uint>,
is_pod: Cell<bool>,
}
fn chunk(size: uint, is_pod: bool) -> Chunk {
Chunk {
- data: Rc::new(RefCell::new(slice::with_capacity(size))),
+ data: Rc::new(RefCell::new(Vec::with_capacity(size))),
fill: Cell::new(0u),
is_pod: Cell::new(is_pod),
}
#[cfg(test)]
mod tests {
extern crate test;
+
+ use std::vec_ng::Vec;
+
use self::test::BenchHarness;
use super::{Arena, TypedArena};
struct Nonpod {
string: ~str,
- array: ~[int],
+ array: Vec<int> ,
}
#[test]
for _ in range(0, 100000) {
arena.alloc(Nonpod {
string: ~"hello world",
- array: ~[ 1, 2, 3, 4, 5 ],
+ array: vec!( 1, 2, 3, 4, 5 ),
});
}
}
bh.iter(|| {
arena.alloc(Nonpod {
string: ~"hello world",
- array: ~[ 1, 2, 3, 4, 5 ],
+ array: vec!( 1, 2, 3, 4, 5 ),
})
})
}
bh.iter(|| {
~Nonpod {
string: ~"hello world",
- array: ~[ 1, 2, 3, 4, 5 ],
+ array: vec!( 1, 2, 3, 4, 5 ),
}
})
}
bh.iter(|| {
arena.alloc(|| Nonpod {
string: ~"hello world",
- array: ~[ 1, 2, 3, 4, 5 ],
+ array: vec!( 1, 2, 3, 4, 5 ),
})
})
}