From 8b7a9367fa8cf137f2986f622557d1e81cf1d8e9 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 1 Mar 2022 18:21:53 -0800 Subject: [PATCH] Avoid storing type name string on AnyViewHandle It won't be needed for leak error messages, because the typed view handle will typically be created first. And this avoids increasing the size of the handle used in production. --- crates/gpui/src/app.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 3f6146d34822e4baf997aa3f2fb44ca32056b869..59be4e7a6dbfec14dc7fcd1031ef2989c3b7647c 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -15,7 +15,7 @@ use platform::Event; use postage::oneshot; use smol::prelude::*; use std::{ - any::{self, type_name, Any, TypeId}, + any::{type_name, Any, TypeId}, cell::RefCell, collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque}, fmt::{self, Debug}, @@ -3382,8 +3382,8 @@ pub struct AnyViewHandle { window_id: usize, view_id: usize, view_type: TypeId, - type_name: &'static str, ref_counts: Arc>, + #[cfg(any(test, feature = "test-support"))] handle_id: usize, } @@ -3393,7 +3393,6 @@ impl AnyViewHandle { window_id: usize, view_id: usize, view_type: TypeId, - type_name: &'static str, ref_counts: Arc>, ) -> Self { ref_counts.lock().inc_view(window_id, view_id); @@ -3403,13 +3402,12 @@ impl AnyViewHandle { .lock() .leak_detector .lock() - .handle_created(Some(type_name), view_id); + .handle_created(None, view_id); Self { window_id, view_id, view_type, - type_name, ref_counts, #[cfg(any(test, feature = "test-support"))] handle_id, @@ -3456,7 +3454,6 @@ impl Clone for AnyViewHandle { self.window_id, self.view_id, self.view_type, - self.type_name, self.ref_counts.clone(), ) } @@ -3474,7 +3471,6 @@ impl From<&ViewHandle> for AnyViewHandle { handle.window_id, handle.view_id, TypeId::of::(), - any::type_name::(), handle.ref_counts.clone(), ) } @@ -3486,7 +3482,6 @@ impl From> for AnyViewHandle { window_id: handle.window_id, view_id: handle.view_id, view_type: TypeId::of::(), - type_name: any::type_name::(), ref_counts: handle.ref_counts.clone(), #[cfg(any(test, feature = "test-support"))] handle_id: handle.handle_id,