mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Replace uses of for foo in bar.iter()
and for foo in bar.iter_mut()
closes #7197
This commit is contained in:
parent
13e7de482c
commit
0038580abf
55 changed files with 141 additions and 154 deletions
|
@ -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
|
||||
|
@ -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({},{},{},{}). {:?}",
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -222,4 +222,3 @@ fn sepia(amount: AzFloat) -> Matrix5x4 {
|
|||
m14: 0.0, m24: 0.0, m34: 0.0, m44: 1.0, m54: 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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() {
|
||||
|
|
|
@ -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 => {
|
||||
|
@ -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 &&
|
||||
|
@ -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();
|
||||
|
|
|
@ -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()
|
||||
|
@ -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())
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue