forge
Explore
Log in

Don't you dare go Hollow

Remove Vec from Shadow::render()

Browse files at this commit

818248457210f5101459ea7d7066d12c456c8a97Ivan MolodetskikhParent: 0584dd2
src/layout/mod.rsmodified+3 -3
@@ -3994,12 +3994,12 @@ impl<W: LayoutElement> Layout<W> {
39943994 }
39953995 }
39963996
3997- pub fn render_floating_for_output<R: NiriRenderer>(
3998- &self,
3997+ pub fn render_floating_for_output<'a, R: NiriRenderer + 'a>(
3998+ &'a self,
39993999 renderer: &mut R,
40004000 output: &Output,
40014001 target: RenderTarget,
4002- ) -> impl Iterator<Item = TileRenderElement<R>> {
4002+ ) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
40034003 if self.update_render_elements_time != self.clock.now() {
40044004 error!("clock moved between updating render elements and rendering");
40054005 }
src/layout/shadow.rsmodified+6 -13
@@ -157,26 +157,19 @@ impl Shadow {
157157 &self,
158158 renderer: &mut impl NiriRenderer,
159159 location: Point<f64, Logical>,
160- ) -> impl Iterator<Item = ShadowRenderElement> {
161- let mut rv = Vec::new();
162-
160+ ) -> impl Iterator<Item = ShadowRenderElement> + '_ {
163161 if !self.config.on {
164- return rv.into_iter();
162+ return None.into_iter().flatten();
165163 }
166164
167165 let has_shadow_shader = ShadowRenderElement::has_shader(renderer);
168166 if !has_shadow_shader {
169- return rv.into_iter();
167+ return None.into_iter().flatten();
170168 }
171169
172- let mut push = |shader: &ShadowRenderElement, location: Point<f64, Logical>| {
173- rv.push(shader.clone().with_location(location));
174- };
175-
176- for (shader, rect) in zip(&self.shaders, &self.shader_rects) {
177- push(shader, location + rect.loc);
178- }
170+ let rv = zip(&self.shaders, &self.shader_rects)
171+ .map(move |(shader, rect)| shader.clone().with_location(location + rect.loc));
179172
180- rv.into_iter()
173+ Some(rv).into_iter().flatten()
181174 }
182175 }
src/layout/tile.rsmodified+6 -6
@@ -710,14 +710,14 @@ impl<W: LayoutElement> Tile<W> {
710710 .unwrap_or_else(|| !self.window.has_ssd())
711711 }
712712
713- fn render_inner<R: NiriRenderer>(
714- &self,
713+ fn render_inner<'a, R: NiriRenderer + 'a>(
714+ &'a self,
715715 renderer: &mut R,
716716 location: Point<f64, Logical>,
717717 scale: Scale<f64>,
718718 focus_ring: bool,
719719 target: RenderTarget,
720- ) -> impl Iterator<Item = TileRenderElement<R>> {
720+ ) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
721721 let _span = tracy_client::span!("Tile::render_inner");
722722
723723 let alpha = if self.is_fullscreen {
@@ -926,14 +926,14 @@ impl<W: LayoutElement> Tile<W> {
926926 rv.chain(self.shadow.render(renderer, location).map(Into::into))
927927 }
928928
929- pub fn render<R: NiriRenderer>(
930- &self,
929+ pub fn render<'a, R: NiriRenderer + 'a>(
930+ &'a self,
931931 renderer: &mut R,
932932 location: Point<f64, Logical>,
933933 scale: Scale<f64>,
934934 focus_ring: bool,
935935 target: RenderTarget,
936- ) -> impl Iterator<Item = TileRenderElement<R>> {
936+ ) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
937937 let _span = tracy_client::span!("Tile::render");
938938
939939 let mut open_anim_elem = None;