From 9a25fcfc82b72f60facd381786ca5490acca032c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Jun 2026 02:42:02 +0900 Subject: feat(dependency-resolver): share operations via Rc, drop clone_box OperationInterface::clone_box (a todo!() trait-object clone stub) is removed in favor of Rc shared ownership. All its methods are &self, so operations are immutable value objects that Rc can share; pushing the same operation into multiple lists (installer's install/uninstall splits) becomes a cheap Rc clone instead of clone_box. Box is replaced with Rc across Transaction (and its Lock/LocalRepo wrappers), Installer, PackageEvent, InstallationManager and EventDispatcher; Box::new operation constructions become Rc::new. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/installer/installation_manager.rs | 18 +++++++++--------- crates/shirabe/src/installer/package_event.rs | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'crates/shirabe/src/installer') diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs index 8275b41..2fc77d9 100644 --- a/crates/shirabe/src/installer/installation_manager.rs +++ b/crates/shirabe/src/installer/installation_manager.rs @@ -169,7 +169,7 @@ impl InstallationManager { pub fn execute( &mut self, repo: &mut dyn InstalledRepositoryInterface, - operations: Vec>, + operations: Vec>, dev_mode: bool, run_scripts: bool, download_only: bool, @@ -200,8 +200,8 @@ impl InstallationManager { let result: Result<()> = (|| -> Result<()> { // execute operations in batches to make sure download-modifying-plugins are installed // before the other packages get downloaded - let mut batches: Vec>> = vec![]; - let mut batch: IndexMap> = IndexMap::new(); + let mut batches: Vec>> = vec![]; + let mut batch: IndexMap> = IndexMap::new(); for (index, operation) in operations.into_iter().enumerate() { let index = index as i64; let package: Option = @@ -287,7 +287,7 @@ impl InstallationManager { async fn download_and_execute_batch( &mut self, repo: &mut dyn InstalledRepositoryInterface, - operations: IndexMap>, + operations: IndexMap>, cleanup_promises: &mut IndexMap< i64, Box< @@ -298,7 +298,7 @@ impl InstallationManager { dev_mode: bool, run_scripts: bool, download_only: bool, - all_operations: Vec>, + all_operations: Vec>, ) -> Result<()> { for (index, operation) in &operations { let op_type = operation.get_operation_type(); @@ -359,8 +359,8 @@ impl InstallationManager { // execute operations in batches to make sure every plugin is installed in the // right order and activated before the packages depending on it are installed - let mut batches: Vec>> = vec![]; - let mut batch: IndexMap> = IndexMap::new(); + let mut batches: Vec>> = vec![]; + let mut batch: IndexMap> = IndexMap::new(); for (index, operation) in operations { let package: Option = if let Some(update) = operation.as_update_operation() { @@ -411,7 +411,7 @@ impl InstallationManager { async fn execute_batch( &mut self, repo: &mut dyn InstalledRepositoryInterface, - operations: IndexMap>, + operations: IndexMap>, cleanup_promises: &IndexMap< i64, Box< @@ -421,7 +421,7 @@ impl InstallationManager { >, dev_mode: bool, run_scripts: bool, - all_operations: &[Box], + all_operations: &[std::rc::Rc], ) -> Result<()> { let mut post_exec_callbacks: Vec> = vec![]; diff --git a/crates/shirabe/src/installer/package_event.rs b/crates/shirabe/src/installer/package_event.rs index 342732d..17f9113 100644 --- a/crates/shirabe/src/installer/package_event.rs +++ b/crates/shirabe/src/installer/package_event.rs @@ -14,8 +14,8 @@ pub struct PackageEvent { io: std::rc::Rc>, dev_mode: bool, local_repo: Box, - operations: Vec>, - operation: Box, + operations: Vec>, + operation: std::rc::Rc, } impl PackageEvent { @@ -25,8 +25,8 @@ impl PackageEvent { io: std::rc::Rc>, dev_mode: bool, local_repo: Box, - operations: Vec>, - operation: Box, + operations: Vec>, + operation: std::rc::Rc, ) -> Self { Self { inner: Event::new(event_name, vec![], IndexMap::new()), @@ -59,7 +59,7 @@ impl PackageEvent { self.local_repo.as_ref() } - pub fn get_operations(&self) -> &Vec> { + pub fn get_operations(&self) -> &Vec> { &self.operations } -- cgit v1.3.1