Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
chore: Hoist non-generic part out of add_action_internal. (#2981)
Piotr Osiewicz0598a8243d29
diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rsindex c95c0a61056..6b3cd03e8fa 100644--- a/crates/gpui/src/app.rs+++ b/crates/gpui/src/app.rs@@ -684,23 +684,41 @@ impl AppContext {);},);+ fn inner(+ this: &mut AppContext,+ name: &'static str,+ deserializer: fn(serde_json::Value) -> anyhow::Result<Box<dyn Action>>,+ action_id: TypeId,+ view_id: TypeId,+ handler: Box<ActionCallback>,+ capture: bool,+ ) {+ this.action_deserializers+ .entry(name)+ .or_insert((action_id.clone(), deserializer));++ let actions = if capture {+ &mut this.capture_actions+ } else {+ &mut this.actions+ };- self.action_deserializers- .entry(A::qualified_name())- .or_insert((TypeId::of::<A>(), A::from_json_str));-- let actions = if capture {- &mut self.capture_actions- } else {- &mut self.actions- };-- actions- .entry(TypeId::of::<V>())- .or_default()- .entry(TypeId::of::<A>())- .or_default()- .push(handler);+ actions+ .entry(view_id)+ .or_default()+ .entry(action_id)+ .or_default()+ .push(handler);+ }+ inner(+ self,+ A::qualified_name(),+ A::from_json_str,+ TypeId::of::<A>(),+ TypeId::of::<V>(),+ handler,+ capture,+ );}pub fn add_async_action<A, V, F>(&mut self, mut handler: F)