From 222012294e953a0f5bf6e442b8a61116235c86b5 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Jun 2026 02:31:07 +0900 Subject: feat(dependency-resolver): share policy via Rc, drop clone_box PolicyInterface::clone_box (a todo!() trait-object clone stub) is removed in favor of Rc shared ownership, matching PHP's by-reference sharing of the single $policy object across Solver, RuleSetGenerator and PoolOptimizer. With PoolOptimizer::new now taking an Rc, Installer::create_pool_optimizer is implemented faithfully (return new PoolOptimizer($policy)); create_policy returns the shared Rc. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/installer.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/installer.rs') diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs index efc41c1..1f63f35 100644 --- a/crates/shirabe/src/installer.rs +++ b/crates/shirabe/src/installer.rs @@ -710,7 +710,7 @@ impl Installer { &mut lock_transaction, &platform_repo, &aliases, - &policy, + &*policy, locked_repository.as_ref(), )?; if exit_code != 0 { @@ -1401,7 +1401,7 @@ impl Installer { &mut self, for_update: bool, locked_repo: Option<&crate::repository::LockArrayRepositoryHandle>, - ) -> DefaultPolicy { + ) -> std::rc::Rc { let mut prefer_stable: Option = None; let mut prefer_lowest: Option = None; if !for_update { @@ -1437,11 +1437,11 @@ impl Installer { preferred_versions = Some(versions); } - DefaultPolicy::new( + std::rc::Rc::new(DefaultPolicy::new( prefer_stable.unwrap(), prefer_lowest.unwrap(), preferred_versions, - ) + )) } fn create_request( @@ -1615,7 +1615,10 @@ impl Installer { )); } - fn create_pool_optimizer(&self, policy: &dyn PolicyInterface) -> Option { + fn create_pool_optimizer( + &self, + policy: std::rc::Rc, + ) -> Option { // Not the best architectural decision here, would need to be able // to configure from the outside of Installer but this is only // a debugging tool and should never be required in any other use case @@ -1629,9 +1632,7 @@ impl Installer { return None; } - // TODO(phase-b): PoolOptimizer::new takes owned Box; have &dyn - let _ = policy; - todo!() + Some(PoolOptimizer::new(policy)) } fn get_audit_config(&mut self) -> anyhow::Result<&AuditConfig> { -- cgit v1.3.1