Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Avoid unnecessary call to `with_element_id` in `RenderViewWith`
Antonio Scandurra759ce7440cdd
diff --git a/crates/gpui2/src/view.rs b/crates/gpui2/src/view.rsindex 5a2cc0f1036..3edaa900b04 100644--- a/crates/gpui2/src/view.rs+++ b/crates/gpui2/src/view.rs@@ -1,7 +1,7 @@use crate::{private::Sealed, AnyBox, AnyElement, AnyModel, AnyWeakModel, AppContext, AvailableSpace,- BorrowWindow, Bounds, Component, Element, ElementId, Entity, EntityId, Flatten, LayoutId,- Model, Pixels, Size, ViewContext, VisualContext, WeakModel, WindowContext,+ Bounds, Component, Element, ElementId, Entity, EntityId, Flatten, LayoutId, Model, Pixels,+ Size, ViewContext, VisualContext, WeakModel, WindowContext,};use anyhow::{Context, Result};use std::{@@ -325,12 +325,10 @@ where_: Option<Self::ElementState>,cx: &mut ViewContext<ParentViewState>,) -> Self::ElementState {- cx.with_element_id(Some(self.view.entity_id()), |cx| {- self.view.update(cx, |view, cx| {- let mut element = self.component.take().unwrap().render();- element.initialize(view, cx);- element- })+ self.view.update(cx, |view, cx| {+ let mut element = self.component.take().unwrap().render();+ element.initialize(view, cx);+ element})}@@ -340,9 +338,7 @@ whereelement: &mut Self::ElementState,cx: &mut ViewContext<ParentViewState>,) -> LayoutId {- cx.with_element_id(Some(self.view.entity_id()), |cx| {- self.view.update(cx, |view, cx| element.layout(view, cx))- })+ self.view.update(cx, |view, cx| element.layout(view, cx))}fn paint(@@ -352,9 +348,7 @@ whereelement: &mut Self::ElementState,cx: &mut ViewContext<ParentViewState>,) {- cx.with_element_id(Some(self.view.entity_id()), |cx| {- self.view.update(cx, |view, cx| element.paint(view, cx))- })+ self.view.update(cx, |view, cx| element.paint(view, cx))}}