diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-05 02:31:07 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-05 02:31:07 +0900 |
| commit | 222012294e953a0f5bf6e442b8a61116235c86b5 (patch) | |
| tree | f31bcb2d7b4c91f962be27c052db803ac6187767 /crates/shirabe/src/installer.rs | |
| parent | d59da23db4aeabd1c6807bcddce562e19b645796 (diff) | |
| download | php-shirabe-222012294e953a0f5bf6e442b8a61116235c86b5.tar.gz php-shirabe-222012294e953a0f5bf6e442b8a61116235c86b5.tar.zst php-shirabe-222012294e953a0f5bf6e442b8a61116235c86b5.zip | |
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<dyn PolicyInterface> 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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer.rs')
| -rw-r--r-- | crates/shirabe/src/installer.rs | 17 |
1 files changed, 9 insertions, 8 deletions
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<dyn PolicyInterface> { let mut prefer_stable: Option<bool> = None; let mut prefer_lowest: Option<bool> = 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<PoolOptimizer> { + fn create_pool_optimizer( + &self, + policy: std::rc::Rc<dyn PolicyInterface>, + ) -> Option<PoolOptimizer> { // 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<dyn PolicyInterface>; have &dyn - let _ = policy; - todo!() + Some(PoolOptimizer::new(policy)) } fn get_audit_config(&mut self) -> anyhow::Result<&AuditConfig> { |
