Skip to content

Commit

Permalink
Convert Vec::new() to vec!()
Browse files Browse the repository at this point in the history
  • Loading branch information
murphm8 authored and Ms2ger committed May 4, 2014
1 parent 4d595b7 commit af920f4
Show file tree
Hide file tree
Showing 39 changed files with 133 additions and 134 deletions.
2 changes: 1 addition & 1 deletion src/components/gfx/buffer_map.rs
Expand Up @@ -86,7 +86,7 @@ impl<T: Tile> BufferMap<T> {
// use lazy insertion function to prevent unnecessary allocation
let counter = &self.counter;
self.map.find_or_insert_with(new_key, |_| BufferValue {
buffers: Vec::new(),
buffers: vec!(),
last_action: *counter
}).buffers.push(new_buffer);

Expand Down
4 changes: 2 additions & 2 deletions src/components/gfx/font.rs
Expand Up @@ -160,7 +160,7 @@ impl FontGroup {
}

pub fn teardown(&mut self) {
self.fonts = Vec::new();
self.fonts = vec!();
}

pub fn create_textrun(&self, text: ~str, decoration: text_decoration::T) -> TextRun {
Expand Down Expand Up @@ -361,7 +361,7 @@ impl Font {
};

let mut origin = baseline_origin.clone();
let mut azglyphs = Vec::new();
let mut azglyphs = vec!();
azglyphs.reserve(range.length());

for (glyphs, _offset, slice_range) in run.iter_slices_for_range(range) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/gfx/font_context.rs
Expand Up @@ -116,7 +116,7 @@ impl FontContext {
}

fn create_font_group(&mut self, style: &SpecifiedFontStyle) -> Rc<RefCell<FontGroup>> {
let mut fonts = Vec::new();
let mut fonts = vec!();

debug!("(create font group) --- starting ---");

Expand Down
2 changes: 1 addition & 1 deletion src/components/gfx/font_list.rs
Expand Up @@ -91,7 +91,7 @@ impl FontFamily {
pub fn new(family_name: &str) -> FontFamily {
FontFamily {
family_name: family_name.to_str(),
entries: Vec::new(),
entries: vec!(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/gfx/render_task.rs
Expand Up @@ -293,7 +293,7 @@ impl<C: RenderListener + Send> RenderTask<C> {
fn render(&mut self, tiles: Vec<BufferRequest>, scale: f32, layer_id: LayerId) {
time::profile(time::RenderingCategory, self.profiler_chan.clone(), || {
// FIXME: Try not to create a new array here.
let mut new_buffers = Vec::new();
let mut new_buffers = vec!();

// Find the appropriate render layer.
let render_layer = match self.render_layers.iter().find(|layer| layer.id == layer_id) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/gfx/text/glyph.rs
Expand Up @@ -310,8 +310,8 @@ struct DetailedGlyphStore {
impl<'a> DetailedGlyphStore {
fn new() -> DetailedGlyphStore {
DetailedGlyphStore {
detail_buffer: Vec::new(), // TODO: default size?
detail_lookup: Vec::new(),
detail_buffer: vec!(), // TODO: default size?
detail_lookup: vec!(),
lookup_is_sorted: false
}
}
Expand Down Expand Up @@ -403,7 +403,7 @@ impl<'a> DetailedGlyphStore {
// immutable locations thus don't play well with freezing.

// Thar be dragons here. You have been warned. (Tips accepted.)
let mut unsorted_records: Vec<DetailedGlyphRecord> = Vec::new();
let mut unsorted_records: Vec<DetailedGlyphRecord> = vec!();
mem::swap(&mut self.detail_lookup, &mut unsorted_records);
let mut mut_records : Vec<DetailedGlyphRecord> = unsorted_records;
mut_records.sort_by(|a, b| {
Expand Down
2 changes: 1 addition & 1 deletion src/components/gfx/text/shaping/harfbuzz.rs
Expand Up @@ -411,7 +411,7 @@ impl Shaper {
glyphs.add_glyph_for_char_index(char_idx, &data);
} else {
// collect all glyphs to be assigned to the first character.
let mut datas = Vec::new();
let mut datas = vec!();

for glyph_i in glyph_span.eachi() {
let shape = glyph_data.get_entry_for_glyph(glyph_i, &mut y_pos);
Expand Down
2 changes: 1 addition & 1 deletion src/components/gfx/text/text_run.rs
Expand Up @@ -116,7 +116,7 @@ impl<'a> TextRun {
pub fn break_and_shape(font: &mut Font, text: &str) -> Vec<Arc<GlyphStore>> {
// TODO(Issue #230): do a better job. See Gecko's LineBreaker.

let mut glyphs = Vec::new();
let mut glyphs = vec!();
let mut byte_i = 0u;
let mut cur_slice_is_whitespace = false;
let mut byte_last_boundary = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/components/gfx/text/util.rs
Expand Up @@ -149,7 +149,7 @@ fn test_transform_compress_none() {
let mode = CompressNone;

for i in range(0, test_strs.len()) {
let mut new_line_pos = Vec::new();
let mut new_line_pos = vec!();
let (trimmed_str, _out) = transform_text(test_strs[i], mode, true, &mut new_line_pos);
assert_eq!(&trimmed_str, &test_strs[i])
}
Expand Down Expand Up @@ -178,7 +178,7 @@ fn test_transform_discard_newline() {
let mode = DiscardNewline;

for i in range(0, test_strs.len()) {
let mut new_line_pos = Vec::new();
let mut new_line_pos = vec!();
let (trimmed_str, _out) = transform_text(test_strs[i], mode, true, &mut new_line_pos);
assert_eq!(&trimmed_str, &oracle_strs[i])
}
Expand Down Expand Up @@ -266,7 +266,7 @@ fn test_transform_compress_whitespace_newline_no_incoming() {
let mode = CompressWhitespaceNewline;

for i in range(0, test_strs.len()) {
let mut new_line_pos = Vec::new();
let mut new_line_pos = vec!();
let (trimmed_str, _out) = transform_text(test_strs[i], mode, false, &mut new_line_pos);
assert_eq!(&trimmed_str, &oracle_strs[i])
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/main/compositing/compositor_layer.rs
Expand Up @@ -170,7 +170,7 @@ impl CompositorLayer {
bounds: bounds,
page_size: page_size,
scroll_offset: Point2D(0f32, 0f32),
children: Vec::new(),
children: vec!(),
quadtree: match page_size {
None => NoTree(tile_size, Some(MAX_TILE_MEMORY_PER_LAYER)),
Some(page_size) => {
Expand Down Expand Up @@ -203,7 +203,7 @@ impl CompositorLayer {
bounds: Rect(Point2D(0f32, 0f32), page_size),
page_size: Some(page_size),
scroll_offset: Point2D(0f32, 0f32),
children: Vec::new(),
children: vec!(),
quadtree: NoTree(tile_size, Some(MAX_TILE_MEMORY_PER_LAYER)),
root_layer: Rc::new(ContainerLayer()),
hidden: false,
Expand Down Expand Up @@ -841,7 +841,7 @@ impl CompositorLayer {
Tree(ref mut quadtree) => quadtree,
};

let mut unused_tiles = Vec::new();
let mut unused_tiles = vec!();
for buffer in new_buffers.buffers.move_iter() {
unused_tiles.push_all_move(quadtree.add_tile_pixel(buffer.screen_pos.origin.x,
buffer.screen_pos.origin.y,
Expand Down
20 changes: 10 additions & 10 deletions src/components/main/compositing/quadtree.rs
Expand Up @@ -269,7 +269,7 @@ impl<T: Tile> QuadtreeNode<T> {

/// Get all tiles in the tree, parents first.
fn get_all_tiles<'r>(&'r self) -> Vec<&'r T> {
let mut ret = Vec::new();
let mut ret = vec!();

match self.tile {
Some(ref tile) => ret.push(tile),
Expand Down Expand Up @@ -303,7 +303,7 @@ impl<T: Tile> QuadtreeNode<T> {
self.tile_mem = tile.get_mem();
let mut unused_tiles = match replace(&mut self.tile, Some(tile)) {
Some(old_tile) => vec!(old_tile),
None => Vec::new(),
None => vec!(),
};
for child in self.quadrants.mut_iter() {
match *child {
Expand Down Expand Up @@ -479,7 +479,7 @@ impl<T: Tile> QuadtreeNode<T> {
if w_x + w_width < s_x || w_x > s_x + s_size
|| w_y + w_height < s_y || w_y > s_y + s_size
|| w_x >= clip.width || w_y >= clip.height {
return (Vec::new(), Vec::new(), 0);
return (vec!(), vec!(), 0);
}

// clip window to visible region
Expand All @@ -488,15 +488,15 @@ impl<T: Tile> QuadtreeNode<T> {

if s_size <= tile_size { // We are the child
return match self.tile {
_ if self.status == Rendering || self.status == Hidden => (Vec::new(), Vec::new(), 0),
_ if self.status == Rendering || self.status == Hidden => (vec!(), vec!(), 0),
Some(ref tile) if tile.is_valid(scale) && !override
&& self.status != Invalid => {
let redisplay = match self.quadrants {
[None, None, None, None] => false,
_ => true,
};
let mut delta = 0;
let mut unused_tiles = Vec::new();
let mut unused_tiles = vec!();
if redisplay {
let old_mem = self.tile_mem;
for child in self.quadrants.mut_iter() {
Expand All @@ -512,9 +512,9 @@ impl<T: Tile> QuadtreeNode<T> {
delta = self.tile_mem as int - old_mem as int;

}
(Vec::new(), unused_tiles, delta)
(vec!(), unused_tiles, delta)
}
_ => (vec!(self.get_tile_rect(s_x, s_y, clip.width, clip.height, scale, tile_size)), Vec::new(), 0),
_ => (vec!(self.get_tile_rect(s_x, s_y, clip.width, clip.height, scale, tile_size)), vec!(), 0),
}
}

Expand Down Expand Up @@ -548,8 +548,8 @@ impl<T: Tile> QuadtreeNode<T> {

let quads_to_check = slice::build(Some(4), builder);

let mut request = Vec::new();
let mut unused = Vec::new();
let mut request = vec!();
let mut unused = vec!();
let mut delta = 0;

for quad in quads_to_check.iter() {
Expand Down Expand Up @@ -607,7 +607,7 @@ impl<T: Tile> QuadtreeNode<T> {
fn collect_tiles(&mut self) -> Vec<T> {
let mut ret = match replace(&mut self.tile, None) {
Some(tile) => vec!(tile),
None => Vec::new(),
None => vec!(),
};
for child in self.quadrants.mut_iter() {
match *child {
Expand Down
16 changes: 8 additions & 8 deletions src/components/main/constellation.rs
Expand Up @@ -185,8 +185,8 @@ struct NavigationContext {
impl NavigationContext {
fn new() -> NavigationContext {
NavigationContext {
previous: Vec::new(),
next: Vec::new(),
previous: vec!(),
next: vec!(),
current: None,
}
}
Expand All @@ -211,7 +211,7 @@ impl NavigationContext {
/// Loads a new set of page frames, returning all evicted frame trees
fn load(&mut self, frame_tree: Rc<FrameTree>) -> Vec<Rc<FrameTree>> {
debug!("navigating to {:?}", frame_tree.pipeline.id);
let evicted = replace(&mut self.next, Vec::new());
let evicted = replace(&mut self.next, vec!());
if self.current.is_some() {
self.previous.push(self.current.take_unwrap());
}
Expand Down Expand Up @@ -265,7 +265,7 @@ impl Constellation {
pipelines: HashMap::new(),
navigation_context: NavigationContext::new(),
next_pipeline_id: PipelineId(0),
pending_frames: Vec::new(),
pending_frames: vec!(),
pending_sizes: HashMap::new(),
profiler_chan: profiler_chan,
window_size: Size2D(800u, 600u),
Expand Down Expand Up @@ -438,7 +438,7 @@ impl Constellation {
after: Rc::new(FrameTree {
pipeline: pipeline_wrapped.clone(),
parent: RefCell::new(None),
children: RefCell::new(Vec::new()),
children: RefCell::new(vec!()),
}),
navigation_type: constellation_msg::Load,
});
Expand All @@ -464,7 +464,7 @@ impl Constellation {
after: Rc::new(FrameTree {
pipeline: pipeline_wrapped.clone(),
parent: RefCell::new(None),
children: RefCell::new(Vec::new()),
children: RefCell::new(vec!()),
}),
navigation_type: constellation_msg::Load,
});
Expand Down Expand Up @@ -611,7 +611,7 @@ impl Constellation {
frame_tree: Rc::new(FrameTree {
pipeline: pipeline_wrapped.clone(),
parent: RefCell::new(Some(source_pipeline.clone())),
children: RefCell::new(Vec::new()),
children: RefCell::new(vec!()),
}),
rect: rect,
});
Expand Down Expand Up @@ -664,7 +664,7 @@ impl Constellation {
after: Rc::new(FrameTree {
pipeline: pipeline_wrapped.clone(),
parent: parent,
children: RefCell::new(Vec::new()),
children: RefCell::new(vec!()),
}),
navigation_type: constellation_msg::Load,
});
Expand Down
10 changes: 5 additions & 5 deletions src/components/main/layout/box_.rs
Expand Up @@ -313,7 +313,7 @@ impl Box {
border_padding: Zero::zero(),
margin: Zero::zero(),
specific: constructor.build_specific_box_info_for_node(node),
new_line_pos: Vec::new(),
new_line_pos: vec!(),
}
}

Expand All @@ -326,7 +326,7 @@ impl Box {
border_padding: Zero::zero(),
margin: Zero::zero(),
specific: specific,
new_line_pos: Vec::new(),
new_line_pos: vec!(),
}
}

Expand All @@ -350,7 +350,7 @@ impl Box {
border_padding: Zero::zero(),
margin: Zero::zero(),
specific: specific,
new_line_pos: Vec::new(),
new_line_pos: vec!(),
}
}

Expand All @@ -366,7 +366,7 @@ impl Box {
border_padding: Zero::zero(),
margin: Zero::zero(),
specific: specific,
new_line_pos: Vec::new(),
new_line_pos: vec!(),
}
}

Expand Down Expand Up @@ -1114,7 +1114,7 @@ impl Box {
let new_text_box_info = ScannedTextBoxInfo::new(text_box_info.run.clone(), left_range);
let new_metrics = new_text_box_info.run.metrics_for_range(&left_range);
let mut new_box = self.transform(new_metrics.bounding_box.size, ScannedTextBox(new_text_box_info));
new_box.new_line_pos = Vec::new();
new_box.new_line_pos = vec!();
Some(new_box)
};

Expand Down
10 changes: 5 additions & 5 deletions src/components/main/layout/construct.rs
Expand Up @@ -502,7 +502,7 @@ impl<'a> FlowConstructor<'a> {
whitespace_stripping,
node);
if !consecutive_siblings.is_empty() {
let consecutive_siblings = mem::replace(consecutive_siblings, Vec::new());
let consecutive_siblings = mem::replace(consecutive_siblings, vec!());
self.generate_anonymous_missing_child(consecutive_siblings,
flow,
node);
Expand Down Expand Up @@ -588,7 +588,7 @@ impl<'a> FlowConstructor<'a> {
-> ConstructionResult {
// Gather up boxes for the inline flows we might need to create.
let mut inline_box_accumulator = InlineBoxAccumulator::new();
let mut consecutive_siblings = Vec::new();
let mut consecutive_siblings = vec!();
let mut first_box = true;

// List of absolute descendants, in tree order.
Expand Down Expand Up @@ -811,15 +811,15 @@ impl<'a> FlowConstructor<'a> {
flow: &mut ~Flow:Share,
node: &ThreadSafeLayoutNode) {
let mut anonymous_flow = flow.generate_missing_child_flow(node);
let mut consecutive_siblings = Vec::new();
let mut consecutive_siblings = vec!();
for kid_flow in child_flows.move_iter() {
if anonymous_flow.need_anonymous_flow(kid_flow) {
consecutive_siblings.push(kid_flow);
continue;
}
if !consecutive_siblings.is_empty() {
self.generate_anonymous_missing_child(consecutive_siblings, &mut anonymous_flow, node);
consecutive_siblings = Vec::new();
consecutive_siblings = vec!();
}
anonymous_flow.add_new_child(kid_flow);
}
Expand Down Expand Up @@ -931,7 +931,7 @@ impl<'a> FlowConstructor<'a> {
fn build_flow_for_table_colgroup(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
let box_ = Box::new_from_specific_info(node,
TableColumnBox(TableColumnBoxInfo::new(node)));
let mut col_boxes = Vec::new();
let mut col_boxes = vec!();
for kid in node.children() {
// CSS 2.1 § 17.2.1. Treat all non-column child boxes of `table-column-group`
// as `display: none`.
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/layout/floats.rs
Expand Up @@ -58,7 +58,7 @@ struct FloatList {
impl FloatList {
fn new() -> FloatList {
FloatList {
floats: Vec::new(),
floats: vec!(),
max_top: Au(0),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/layout/layout_task.rs
Expand Up @@ -795,7 +795,7 @@ impl LayoutTask {
}
}

let mut boxes = Vec::new();
let mut boxes = vec!();
match self.display_list {
None => fail!("no display list!"),
Some(ref display_list) => {
Expand Down

0 comments on commit af920f4

Please sign in to comment.