Return impl IntoElement in Render and RenderOnce traits (#3839)

- Returning `IntoElement` because it's more universal than `Element` and
allows us to easily return components.
- Using `impl IntoElement` in `RenderOnce` for consistency, which
requires `Component` to allocate an `AnyElement`. We use a bump
allocated arena anyway for these, and my benchmark doesn't show an
impact.


![frame-time-histogram](https://github.com/zed-industries/zed/assets/1789/d3889cca-9ebc-4d72-aa68-34a5be3bad3c)

In this histogram, frames-0 is this PR, frames-1 is main.

Release Notes:

- N/A
This commit is contained in:
Nathan Sobo
2024-01-03 10:37:26 -07:00
committed by GitHub
117 changed files with 631 additions and 292 deletions
+1 -1
View File
@@ -9287,7 +9287,7 @@ impl FocusableView for Editor {
}
impl Render for Editor {
fn render<'a>(&mut self, cx: &mut ViewContext<'a, Self>) -> impl 'static + Element {
fn render<'a>(&mut self, cx: &mut ViewContext<'a, Self>) -> impl IntoElement {
let settings = ThemeSettings::get_global(cx);
let text_style = match self.mode {
EditorMode::SingleLine | EditorMode::AutoHeight { .. } => TextStyle {
+1 -1
View File
@@ -1193,7 +1193,7 @@ impl CursorPosition {
}
impl Render for CursorPosition {
fn render(&mut self, _: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, _: &mut ViewContext<Self>) -> impl IntoElement {
div().when_some(self.position, |el, position| {
let mut text = format!(
"{}{FILE_ROW_COLUMN_DELIMITER}{}",