Wrap AnyView.cached_style in an Rc to make the struct much smaller (#24363)
Byte size before was 672, now is 56. The `cached` method is only used in two places, so this was a lot of extra bytes being shuffled around for every `AnyView` not using this. Release Notes: - N/A
This commit is contained in:
parent
53fcd7cc92
commit
1f2205d75c
1 changed files with 3 additions and 2 deletions
|
@ -8,6 +8,7 @@ use anyhow::Result;
|
||||||
use collections::FxHashSet;
|
use collections::FxHashSet;
|
||||||
use refineable::Refineable;
|
use refineable::Refineable;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
use std::rc::Rc;
|
||||||
use std::{any::TypeId, fmt, ops::Range};
|
use std::{any::TypeId, fmt, ops::Range};
|
||||||
|
|
||||||
struct AnyViewState {
|
struct AnyViewState {
|
||||||
|
@ -73,7 +74,7 @@ impl<V: Render> Element for Entity<V> {
|
||||||
pub struct AnyView {
|
pub struct AnyView {
|
||||||
entity: AnyEntity,
|
entity: AnyEntity,
|
||||||
render: fn(&AnyView, &mut Window, &mut App) -> AnyElement,
|
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 {
|
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.
|
/// 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.
|
/// The one exception is when [Window::refresh] is called, in which case caching is ignored.
|
||||||
pub fn cached(mut self, style: StyleRefinement) -> Self {
|
pub fn cached(mut self, style: StyleRefinement) -> Self {
|
||||||
self.cached_style = Some(style);
|
self.cached_style = Some(style.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue