Skip to content

Commit

Permalink
Auto merge of #7225 - jxs:master, r=nox
Browse files Browse the repository at this point in the history
Replace uses of `for foo in bar.iter()` and `for foo in bar.iter_mut()`

closes #7197

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7225)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Aug 15, 2015
2 parents 13e7de4 + 0038580 commit a1b3f47
Show file tree
Hide file tree
Showing 55 changed files with 141 additions and 154 deletions.
12 changes: 6 additions & 6 deletions components/compositing/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
-> Rc<Layer<CompositorData>> {
let root_layer = self.create_root_layer_for_pipeline_and_rect(&frame_tree.pipeline,
frame_rect);
for kid in frame_tree.children.iter() {
for kid in &frame_tree.children {
root_layer.add_child(self.create_frame_tree_root_layers(kid, kid.rect));
}
return root_layer;
Expand Down Expand Up @@ -1085,7 +1085,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
process_layer(&**layer, &window_size, &mut new_visible_rects)
}

for (pipeline_id, new_visible_rects) in new_visible_rects.iter() {
for (pipeline_id, new_visible_rects) in &new_visible_rects {
if let Some(pipeline_details) = self.pipeline_details.get(&pipeline_id) {
if let Some(ref pipeline) = pipeline_details.pipeline {
let LayoutControlChan(ref sender) = pipeline.layout_chan;
Expand All @@ -1109,7 +1109,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {

/// If there are any animations running, dispatches appropriate messages to the constellation.
fn process_animations(&mut self) {
for (pipeline_id, pipeline_details) in self.pipeline_details.iter() {
for (pipeline_id, pipeline_details) in &self.pipeline_details {
if pipeline_details.animations_running ||
pipeline_details.animation_callbacks_running {
self.tick_animations_for_pipeline(*pipeline_id)
Expand Down Expand Up @@ -1225,7 +1225,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}

fn fill_paint_request_with_cached_layer_buffers(&mut self, paint_request: &mut PaintRequest) {
for buffer_request in paint_request.buffer_requests.iter_mut() {
for buffer_request in &mut paint_request.buffer_requests {
if self.surface_map.mem() == 0 {
return;
}
Expand Down Expand Up @@ -1261,7 +1261,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {

// All the BufferRequests are in layer/device coordinates, but the paint task
// wants to know the page coordinates. We scale them before sending them.
for request in layer_requests.iter_mut() {
for request in &mut layer_requests {
request.page_rect = request.page_rect / scale.get();
}

Expand Down Expand Up @@ -1393,7 +1393,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
// This gets sent to the constellation for comparison with the current
// frame tree.
let mut pipeline_epochs = HashMap::new();
for (id, details) in self.pipeline_details.iter() {
for (id, details) in &self.pipeline_details {
// If animations are currently running, then don't bother checking
// with the constellation if the output image is stable.
if details.animations_running || details.animation_callbacks_running {
Expand Down
2 changes: 1 addition & 1 deletion components/compositing/constellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let pipeline = self.pipelines.get(&frame.current).unwrap();
let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size));

for pipeline_id in frame.prev.iter().chain(frame.next.iter()) {
for pipeline_id in frame.prev.iter().chain(&frame.next) {
let pipeline = self.pipelines.get(pipeline_id).unwrap();
let _ = pipeline.script_chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size));
}
Expand Down
2 changes: 1 addition & 1 deletion components/devtools/actors/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl TimelineActor {
}

// Emit all markers
for (_, queue) in queues.iter_mut() {
for (_, queue) in &mut queues {
let start_payload = queue.pop_front();
group(queue, 0, start_payload, &mut emitter);
}
Expand Down
8 changes: 4 additions & 4 deletions components/devtools/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
__type__: "networkEvent".to_string(),
eventActor: actor.event_actor(),
};
for stream in connections.iter_mut() {
for stream in &mut connections {
stream.write_json_packet(&msg);
}
}
Expand All @@ -363,7 +363,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
response: actor.response_start()
};

for stream in connections.iter_mut() {
for stream in &mut connections {
stream.write_json_packet(&msg);
}
}
Expand Down Expand Up @@ -429,7 +429,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
request_id, network_event))) => {
// copy the accepted_connections vector
let mut connections = Vec::<TcpStream>::new();
for stream in accepted_connections.iter() {
for stream in &accepted_connections {
connections.push(stream.try_clone().unwrap());
}
//TODO: Get pipeline_id from NetworkEventMessage after fixing the send in http_loader
Expand All @@ -441,7 +441,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
Err(RecvError) => break
}
}
for connection in accepted_connections.iter_mut() {
for connection in &mut accepted_connections {
let _ = connection.shutdown(Shutdown::Both);
}
}
30 changes: 15 additions & 15 deletions components/gfx/display_list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,22 @@ impl DisplayList {
/// inefficient and should only be used for debugging.
pub fn all_display_items(&self) -> Vec<DisplayItem> {
let mut result = Vec::new();
for display_item in self.background_and_borders.iter() {
for display_item in &self.background_and_borders {
result.push((*display_item).clone())
}
for display_item in self.block_backgrounds_and_borders.iter() {
for display_item in &self.block_backgrounds_and_borders {
result.push((*display_item).clone())
}
for display_item in self.floats.iter() {
for display_item in &self.floats {
result.push((*display_item).clone())
}
for display_item in self.content.iter() {
for display_item in &self.content {
result.push((*display_item).clone())
}
for display_item in self.positioned_content.iter() {
for display_item in &self.positioned_content {
result.push((*display_item).clone())
}
for display_item in self.outlines.iter() {
for display_item in &self.outlines {
result.push((*display_item).clone())
}
result
Expand All @@ -178,7 +178,7 @@ impl DisplayList {
pub fn print_items(&self, indentation: String) {
// Closures are so nice!
let doit = |items: &Vec<DisplayItem>| {
for item in items.iter() {
for item in items {
match *item {
DisplayItem::SolidColorClass(ref solid_color) => {
println!("{} SolidColor({},{},{},{}). {:?}",
Expand Down Expand Up @@ -217,7 +217,7 @@ impl DisplayList {
println!("{} Children stacking contexts list length: {}",
indentation,
self.children.len());
for stacking_context in self.children.iter() {
for stacking_context in &self.children {
stacking_context.print(indentation.clone() +
&indentation[0..MIN_INDENTATION_LENGTH]);
}
Expand Down Expand Up @@ -319,7 +319,7 @@ impl StackingContext {

// Sort positioned children according to z-index.
let mut positioned_children: SmallVec<[Arc<StackingContext>; 8]> = SmallVec::new();
for kid in display_list.children.iter() {
for kid in &display_list.children {
if kid.layer.is_none() {
positioned_children.push((*kid).clone());
}
Expand All @@ -335,7 +335,7 @@ impl StackingContext {
paint_subcontext.push_clip_if_applicable();

// Steps 1 and 2: Borders and background for the root.
for display_item in display_list.background_and_borders.iter() {
for display_item in &display_list.background_and_borders {
display_item.draw_into_context(&mut paint_subcontext)
}

Expand All @@ -360,24 +360,24 @@ impl StackingContext {
}

// Step 4: Block backgrounds and borders.
for display_item in display_list.block_backgrounds_and_borders.iter() {
for display_item in &display_list.block_backgrounds_and_borders {
display_item.draw_into_context(&mut paint_subcontext)
}

// Step 5: Floats.
for display_item in display_list.floats.iter() {
for display_item in &display_list.floats {
display_item.draw_into_context(&mut paint_subcontext)
}

// TODO(pcwalton): Step 6: Inlines that generate stacking contexts.

// Step 7: Content.
for display_item in display_list.content.iter() {
for display_item in &display_list.content {
display_item.draw_into_context(&mut paint_subcontext)
}

// Step 8: Positioned descendants with `z-index: auto`.
for display_item in display_list.positioned_content.iter() {
for display_item in &display_list.positioned_content {
display_item.draw_into_context(&mut paint_subcontext)
}

Expand All @@ -402,7 +402,7 @@ impl StackingContext {
}

// Step 10: Outlines.
for display_item in display_list.outlines.iter() {
for display_item in &display_list.outlines {
display_item.draw_into_context(&mut paint_subcontext)
}

Expand Down
7 changes: 3 additions & 4 deletions components/gfx/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn create_filters(draw_target: &DrawTarget,
let mut opacity = 1.0;
let mut filter = draw_target.create_filter(FilterType::Composite);
filter.set_input(CompositeInput, &temporary_draw_target.snapshot());
for style_filter in style_filters.filters.iter() {
for style_filter in &style_filters.filters {
match *style_filter {
filter::Filter::HueRotate(angle) => {
let hue_rotate = draw_target.create_filter(FilterType::ColorMatrix);
Expand Down Expand Up @@ -108,7 +108,7 @@ pub fn create_filters(draw_target: &DrawTarget,

/// Determines if we need a temporary draw target for the given set of filters.
pub fn temporary_draw_target_needed_for_style_filters(filters: &filter::T) -> bool {
for filter in filters.filters.iter() {
for filter in &filters.filters {
match *filter {
filter::Filter::Opacity(value) if value == 1.0 => continue,
_ => return true,
Expand All @@ -121,7 +121,7 @@ pub fn temporary_draw_target_needed_for_style_filters(filters: &filter::T) -> bo
// to expand the draw target size.
pub fn calculate_accumulated_blur(style_filters: &filter::T) -> Au {
let mut accum_blur = Au::new(0);
for style_filter in style_filters.filters.iter() {
for style_filter in &style_filters.filters {
match *style_filter {
filter::Filter::Blur(amount) => {
accum_blur = accum_blur.clone() + amount;
Expand Down Expand Up @@ -222,4 +222,3 @@ fn sepia(amount: AzFloat) -> Matrix5x4 {
m14: 0.0, m24: 0.0, m34: 0.0, m44: 1.0, m54: 0.0,
}
}

8 changes: 4 additions & 4 deletions components/gfx/font_cache_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl FontFamily {

// TODO(Issue #190): if not in the fast path above, do
// expensive matching of weights, etc.
for template in self.templates.iter_mut() {
for template in &mut self.templates {
let maybe_template = template.get_if_matches(fctx, desc);
if maybe_template.is_some() {
return maybe_template;
Expand All @@ -51,7 +51,7 @@ impl FontFamily {
// If a request is made for a font family that exists,
// pick the first valid font in the family if we failed
// to find an exact match for the descriptor.
for template in self.templates.iter_mut() {
for template in &mut self.templates {
let maybe_template = template.get();
if maybe_template.is_some() {
return maybe_template;
Expand All @@ -62,7 +62,7 @@ impl FontFamily {
}

fn add_template(&mut self, identifier: Atom, maybe_data: Option<Vec<u8>>) {
for template in self.templates.iter() {
for template in &self.templates {
if *template.identifier() == identifier {
return;
}
Expand Down Expand Up @@ -235,7 +235,7 @@ impl FontCache {
-> Arc<FontTemplateData> {
let last_resort = get_last_resort_font_families();

for family in last_resort.iter() {
for family in &last_resort {
let family = LowercaseString::new(family);
let maybe_font_in_family = self.find_font_in_local_family(&family, desc);
if maybe_font_in_family.is_some() {
Expand Down
8 changes: 4 additions & 4 deletions components/gfx/font_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ impl FontContext {

let mut fonts: SmallVec<[Rc<RefCell<Font>>; 8]> = SmallVec::new();

for family in style.font_family.0.iter() {
for family in &style.font_family.0 {
// GWTODO: Check on real pages if this is faster as Vec() or HashMap().
let mut cache_hit = false;
for cached_font_entry in self.layout_font_cache.iter() {
for cached_font_entry in &self.layout_font_cache {
if cached_font_entry.family == family.name() {
match cached_font_entry.font {
None => {
Expand Down Expand Up @@ -224,7 +224,7 @@ impl FontContext {
// list of last resort fonts for this platform.
if fonts.is_empty() {
let mut cache_hit = false;
for cached_font_entry in self.fallback_font_cache.iter() {
for cached_font_entry in &self.fallback_font_cache {
let cached_font = cached_font_entry.font.borrow();
if cached_font.descriptor == desc &&
cached_font.requested_pt_size == style.font_size &&
Expand Down Expand Up @@ -265,7 +265,7 @@ impl FontContext {
template: &Arc<FontTemplateData>,
pt_size: Au)
-> Rc<RefCell<ScaledFont>> {
for cached_font in self.paint_font_cache.iter() {
for cached_font in &self.paint_font_cache {
if cached_font.pt_size == pt_size &&
cached_font.identifier == template.identifier {
return cached_font.font.clone();
Expand Down
4 changes: 2 additions & 2 deletions components/gfx/paint_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ impl<'a> PaintContext<'a> {

pub fn remove_transient_clip_if_applicable(&mut self) {
if let Some(old_transient_clip) = mem::replace(&mut self.transient_clip, None) {
for _ in old_transient_clip.complex.iter() {
for _ in &old_transient_clip.complex {
self.draw_pop_clip()
}
self.draw_pop_clip()
Expand All @@ -1141,7 +1141,7 @@ impl<'a> PaintContext<'a> {
self.remove_transient_clip_if_applicable();

self.draw_push_clip(&clip_region.main);
for complex_region in clip_region.complex.iter() {
for complex_region in &clip_region.complex {
// FIXME(pcwalton): Actually draw a rounded rect.
self.push_rounded_rect_clip(&complex_region.rect.to_nearest_azure_rect(),
&complex_region.radii.to_radii_px())
Expand Down
2 changes: 1 addition & 1 deletion components/gfx/paint_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
}, reporter_name, chrome_to_paint_chan, ChromeToPaintMsg::CollectReports);

// Tell all the worker threads to shut down.
for worker_thread in paint_task.worker_threads.iter_mut() {
for worker_thread in &mut paint_task.worker_threads {
worker_thread.exit()
}
}
Expand Down
5 changes: 2 additions & 3 deletions components/layout/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn process_new_animations(rw_data: &mut LayoutTaskData, pipeline_id: Pipelin

// Expire old running animations.
let now = clock_ticks::precise_time_s();
for (_, running_animations) in running_animations.iter_mut() {
for (_, running_animations) in &mut running_animations {
running_animations.retain(|running_animation| now < running_animation.end_time);
}

Expand Down Expand Up @@ -97,7 +97,7 @@ pub fn recalc_style_for_animations(flow: &mut Flow,
let mut damage = RestyleDamage::empty();
flow.mutate_fragments(&mut |fragment| {
if let Some(ref animations) = animations.get(&OpaqueNode(fragment.node.id())) {
for animation in animations.iter() {
for animation in *animations {
let now = clock_ticks::precise_time_s();
let mut progress = (now - animation.start_time) / animation.duration();
if progress > 1.0 {
Expand Down Expand Up @@ -130,4 +130,3 @@ pub fn tick_all_animations(layout_task: &LayoutTask, rw_data: &mut LayoutTaskDat

layout_task.script_chan.send(ConstellationControlMsg::TickAllAnimations(layout_task.id)).unwrap();
}

4 changes: 2 additions & 2 deletions components/layout/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl<'a> FlowConstructor<'a> {

// Build a list of all the inline-block fragments before fragments is moved.
let mut inline_block_flows = vec!();
for fragment in fragments.fragments.iter() {
for fragment in &fragments.fragments {
match fragment.specific {
SpecificFragmentInfo::InlineBlock(ref info) => {
inline_block_flows.push(info.flow_ref.clone())
Expand All @@ -464,7 +464,7 @@ impl<'a> FlowConstructor<'a> {
node.style().writing_mode));

// Add all the inline-block fragments as children of the inline flow.
for inline_block_flow in inline_block_flows.iter() {
for inline_block_flow in &inline_block_flows {
inline_flow_ref.add_new_child(inline_block_flow.clone());
}

Expand Down
Loading

0 comments on commit a1b3f47

Please sign in to comment.