diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-03 11:55:03 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-03 11:55:03 +0900 |
| commit | ae1aa6540761e54a76b8f7984cf93cd3a0d011d0 (patch) | |
| tree | f111e1c73977f0bffb6323b03f4210269b43b297 /crates/mozart-sat-resolver/src/pool_builder.rs | |
| parent | 30ae6c869adc7f3cb87a4d63edd6d0cda89d571d (diff) | |
| download | php-mozart-ae1aa6540761e54a76b8f7984cf93cd3a0d011d0.tar.gz php-mozart-ae1aa6540761e54a76b8f7984cf93cd3a0d011d0.tar.zst php-mozart-ae1aa6540761e54a76b8f7984cf93cd3a0d011d0.zip | |
refactor: switch internal maps/sets from HashMap to IndexMap
Adopt indexmap workspace-wide so iteration order is deterministic and
follows insertion order. The non-deterministic order of std HashMap
otherwise leaks into resolver decisions when multiple valid solutions
exist (e.g. cyclic require pairs under prefer-lowest), making behavior
flaky and divergent from Composer's PHP-array semantics.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-sat-resolver/src/pool_builder.rs')
| -rw-r--r-- | crates/mozart-sat-resolver/src/pool_builder.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/crates/mozart-sat-resolver/src/pool_builder.rs b/crates/mozart-sat-resolver/src/pool_builder.rs index 83684aa..3883d85 100644 --- a/crates/mozart-sat-resolver/src/pool_builder.rs +++ b/crates/mozart-sat-resolver/src/pool_builder.rs @@ -1,5 +1,6 @@ use crate::pool::{Pool, PoolLink, PoolPackageInput}; -use std::collections::{HashSet, VecDeque}; +use indexmap::IndexSet; +use std::collections::VecDeque; /// Builder for constructing a Pool from package metadata. /// @@ -10,13 +11,13 @@ pub struct PoolBuilder { /// Packages to add to the pool. inputs: Vec<PoolPackageInput>, /// Names already added (to avoid duplicates). - added: HashSet<String>, + added: IndexSet<String>, /// Queue of package names that need to be explored. pending_names: VecDeque<String>, /// Package names that have already been explored (returned by next_pending). - explored_names: HashSet<String>, + explored_names: IndexSet<String>, /// Specific platform packages to ignore (from `--ignore-platform-req=name`). - ignore_platform_reqs: HashSet<String>, + ignore_platform_reqs: IndexSet<String>, /// When true, ignore every platform package (php, ext-*, lib-*, composer-*). /// Mirrors `--ignore-platform-reqs` (no value). ignore_all_platform_reqs: bool, @@ -26,16 +27,16 @@ impl PoolBuilder { pub fn new() -> Self { PoolBuilder { inputs: Vec::new(), - added: HashSet::new(), + added: IndexSet::new(), pending_names: VecDeque::new(), - explored_names: HashSet::new(), - ignore_platform_reqs: HashSet::new(), + explored_names: IndexSet::new(), + ignore_platform_reqs: IndexSet::new(), ignore_all_platform_reqs: false, } } /// Set platform requirements to ignore during exploration. - pub fn set_ignore_platform_reqs(&mut self, names: HashSet<String>) { + pub fn set_ignore_platform_reqs(&mut self, names: IndexSet<String>) { self.ignore_platform_reqs = names; } |
