Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Wrap AnyView.cached_style in an Rc to make the struct much smaller (#24363)
Michael Sloan1f2205d75ccb
diff --git a/crates/gpui/src/view.rs b/crates/gpui/src/view.rsindex 86d6def7cc7..c6483ba6ae6 100644--- a/crates/gpui/src/view.rs+++ b/crates/gpui/src/view.rs@@ -8,6 +8,7 @@ use anyhow::Result;use collections::FxHashSet;use refineable::Refineable;use std::mem;+use std::rc::Rc;use std::{any::TypeId, fmt, ops::Range};struct AnyViewState {@@ -73,7 +74,7 @@ impl<V: Render> Element for Entity<V> {pub struct AnyView {entity: AnyEntity,render: fn(&AnyView, &mut Window, &mut App) -> AnyElement,- cached_style: Option<StyleRefinement>,+ cached_style: Option<Rc<StyleRefinement>>,}impl<V: Render> From<Entity<V>> for AnyView {@@ -91,7 +92,7 @@ impl AnyView {/// When using this method, the view's previous layout and paint will be recycled from the previous frame if [Context::notify] has not been called since it was rendered./// The one exception is when [Window::refresh] is called, in which case caching is ignored.pub fn cached(mut self, style: StyleRefinement) -> Self {- self.cached_style = Some(style);+ self.cached_style = Some(style.into());self}