aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/installer.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-05 02:42:02 +0900
committernsfisis <nsfisis@gmail.com>2026-06-05 02:42:02 +0900
commit9a25fcfc82b72f60facd381786ca5490acca032c (patch)
treeb34b36c19f14d57d160b8e4235a8040011bdec60 /crates/shirabe/src/installer.rs
parent886ee829cb191745167dca369045acd3125e5714 (diff)
downloadphp-shirabe-9a25fcfc82b72f60facd381786ca5490acca032c.tar.gz
php-shirabe-9a25fcfc82b72f60facd381786ca5490acca032c.tar.zst
php-shirabe-9a25fcfc82b72f60facd381786ca5490acca032c.zip
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<dyn OperationInterface> 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<dyn OperationInterface> is replaced with Rc<dyn ...> 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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer.rs')
-rw-r--r--crates/shirabe/src/installer.rs39
1 files changed, 20 insertions, 19 deletions
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<Box<dyn OperationInterface>> = vec![];
- let mut uninstalls: Vec<Box<dyn OperationInterface>> = vec![];
+ let mut installs_updates: Vec<std::rc::Rc<dyn OperationInterface>> = vec![];
+ let mut uninstalls: Vec<std::rc::Rc<dyn OperationInterface>> = vec![];
if !lock_transaction.get_operations().is_empty() {
let mut install_names: Vec<String> = vec![];
let mut update_names: Vec<String> = vec![];
let mut uninstall_names: Vec<String> = 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<dyn OperationInterface>, b: &Box<dyn OperationInterface>| -> 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<dyn OperationInterface>,
+ b: &std::rc::Rc<dyn OperationInterface>|
+ -> 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<Box<dyn OperationInterface>> = uninstalls;
+ let mut merged: Vec<std::rc::Rc<dyn OperationInterface>> = uninstalls;
merged.extend(installs_updates);
for operation in &merged {
// collect suggestions