Use more iterators in compositing component

This commit is contained in:
Corey Farwell 2015-11-06 18:19:30 -05:00
parent acc0bf6873
commit 649e50f15c
2 changed files with 8 additions and 8 deletions

View file

@ -2011,13 +2011,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
}
pub fn cache_unused_buffers(&mut self, buffers: Vec<Box<LayerBuffer>>) {
if !buffers.is_empty() {
let surfaces = buffers.into_iter().map(|buffer| {
buffer.native_surface
}).collect();
self.surface_map.insert_surfaces(&self.native_display, surfaces);
}
pub fn cache_unused_buffers<B>(&mut self, buffers: B)
where B: IntoIterator<Item=Box<LayerBuffer>>
{
let surfaces = buffers.into_iter().map(|buffer| buffer.native_surface);
self.surface_map.insert_surfaces(&self.native_display, surfaces);
}
#[allow(dead_code)]

View file

@ -68,7 +68,9 @@ impl SurfaceMap {
}
}
pub fn insert_surfaces(&mut self, display: &NativeDisplay, surfaces: Vec<NativeSurface>) {
pub fn insert_surfaces<I>(&mut self, display: &NativeDisplay, surfaces: I)
where I: IntoIterator<Item=NativeSurface>
{
for surface in surfaces {
self.insert(display, surface);
}