~[] to Vec in main/layout/wrapper.rs

This commit is contained in:
Matt Murphy 2014-04-22 19:51:09 -05:00 committed by Ms2ger
parent 3a8ecb2bb1
commit 60d443da16

View file

@ -204,7 +204,7 @@ impl<'ln> LayoutNode<'ln> {
/// ///
/// FIXME(pcwalton): Terribly inefficient. We should use parallelism. /// FIXME(pcwalton): Terribly inefficient. We should use parallelism.
pub fn traverse_preorder(&self) -> LayoutTreeIterator<'ln> { pub fn traverse_preorder(&self) -> LayoutTreeIterator<'ln> {
let mut nodes = ~[]; let mut nodes = Vec::new();
gather_layout_nodes(self, &mut nodes, false); gather_layout_nodes(self, &mut nodes, false);
LayoutTreeIterator::new(nodes) LayoutTreeIterator::new(nodes)
} }
@ -301,12 +301,12 @@ impl<'a> Iterator<LayoutNode<'a>> for LayoutNodeChildrenIterator<'a> {
// //
// FIXME(pcwalton): Parallelism! Eventually this should just be nuked. // FIXME(pcwalton): Parallelism! Eventually this should just be nuked.
pub struct LayoutTreeIterator<'a> { pub struct LayoutTreeIterator<'a> {
nodes: ~[LayoutNode<'a>], nodes: Vec<LayoutNode<'a>>,
index: uint, index: uint,
} }
impl<'a> LayoutTreeIterator<'a> { impl<'a> LayoutTreeIterator<'a> {
fn new(nodes: ~[LayoutNode<'a>]) -> LayoutTreeIterator<'a> { fn new(nodes: Vec<LayoutNode<'a>>) -> LayoutTreeIterator<'a> {
LayoutTreeIterator { LayoutTreeIterator {
nodes: nodes, nodes: nodes,
index: 0, index: 0,
@ -319,7 +319,7 @@ impl<'a> Iterator<LayoutNode<'a>> for LayoutTreeIterator<'a> {
if self.index >= self.nodes.len() { if self.index >= self.nodes.len() {
None None
} else { } else {
let v = self.nodes[self.index].clone(); let v = self.nodes.get(self.index).clone();
self.index += 1; self.index += 1;
Some(v) Some(v)
} }
@ -327,7 +327,7 @@ impl<'a> Iterator<LayoutNode<'a>> for LayoutTreeIterator<'a> {
} }
/// FIXME(pcwalton): This is super inefficient. /// FIXME(pcwalton): This is super inefficient.
fn gather_layout_nodes<'a>(cur: &LayoutNode<'a>, refs: &mut ~[LayoutNode<'a>], postorder: bool) { fn gather_layout_nodes<'a>(cur: &LayoutNode<'a>, refs: &mut Vec<LayoutNode<'a>>, postorder: bool) {
if !postorder { if !postorder {
refs.push(cur.clone()); refs.push(cur.clone());
} }