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.rs | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'crates/shirabe/src/installer.rs') diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs index 95b9298..7fc3275 100644 --- a/crates/shirabe/src/installer.rs +++ b/crates/shirabe/src/installer.rs @@ -724,15 +724,15 @@ impl Installer { let platform_dev_reqs = self.extract_platform_requirements(&self.package.get_dev_requires()); - let mut installs_updates: Vec> = vec![]; - let mut uninstalls: Vec> = vec![]; + let mut installs_updates: Vec> = vec![]; + let mut uninstalls: Vec> = vec![]; if !lock_transaction.get_operations().is_empty() { let mut install_names: Vec = vec![]; let mut update_names: Vec = vec![]; let mut uninstall_names: Vec = vec![]; for operation in lock_transaction.get_operations() { if let Some(io) = operation.as_install_operation() { - installs_updates.push(operation.clone_box()); + installs_updates.push(operation.clone()); install_names.push(format!( "{}:{}", io.get_package().get_pretty_name(), @@ -752,7 +752,7 @@ impl Installer { continue; } - installs_updates.push(operation.clone_box()); + installs_updates.push(operation.clone()); update_names.push(format!( "{}:{}", uo.get_target_package().get_pretty_name(), @@ -762,7 +762,7 @@ impl Installer { ) )); } else if let Some(uo) = operation.as_uninstall_operation() { - uninstalls.push(operation.clone_box()); + uninstalls.push(operation.clone()); uninstall_names.push(uo.get_package().get_pretty_name().to_string()); } } @@ -809,24 +809,25 @@ impl Installer { } } - let sort_by_name = - |a: &Box, b: &Box| -> i64 { - let a_name: String = if let Some(uo) = a.as_update_operation() { - uo.get_target_package().get_name().to_string() - } else { - a.get_package().get_name().to_string() - }; - let b_name: String = if let Some(uo) = b.as_update_operation() { - uo.get_target_package().get_name().to_string() - } else { - b.get_package().get_name().to_string() - }; - strcmp(&a_name, &b_name) + let sort_by_name = |a: &std::rc::Rc, + b: &std::rc::Rc| + -> i64 { + let a_name: String = if let Some(uo) = a.as_update_operation() { + uo.get_target_package().get_name().to_string() + } else { + a.get_package().get_name().to_string() }; + let b_name: String = if let Some(uo) = b.as_update_operation() { + uo.get_target_package().get_name().to_string() + } else { + b.get_package().get_name().to_string() + }; + strcmp(&a_name, &b_name) + }; usort(&mut uninstalls, &sort_by_name); usort(&mut installs_updates, &sort_by_name); - let mut merged: Vec> = uninstalls; + let mut merged: Vec> = uninstalls; merged.extend(installs_updates); for operation in &merged { // collect suggestions -- cgit v1.3.1