diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-19 23:45:38 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-19 23:45:38 +0900 |
| commit | cd7c3fce2472656b2a1247429751e43350976677 (patch) | |
| tree | 95e8760e3417fc3e63dac28bc0cd823a6af768f2 /crates/shirabe/src/package/root_package.rs | |
| parent | b8fb046bd7c4cd28598bcce9f3955d834ea5d008 (diff) | |
| download | php-shirabe-cd7c3fce2472656b2a1247429751e43350976677.tar.gz php-shirabe-cd7c3fce2472656b2a1247429751e43350976677.tar.zst php-shirabe-cd7c3fce2472656b2a1247429751e43350976677.zip | |
perf(package): hand out link maps behind Rc
PackageInterface::getRequires() and friends return the array of Link objects;
in PHP that is a copy-on-write array of object references, so a caller pays
nothing to look at it. The port returned IndexMap<String, Link> by value, so
every call deep-cloned the whole map, keys and constraints included. Pool
building calls these accessors once per package per candidate, which put
IndexMap::clone at 13.5% of `require laravel/laravel`.
Store the maps as Rc<IndexMap<String, Link>> and return a handle. Callers that
mutate the map clone it explicitly at the point of mutation, matching where PHP
would separate the array.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/package/root_package.rs')
| -rw-r--r-- | crates/shirabe/src/package/root_package.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/shirabe/src/package/root_package.rs b/crates/shirabe/src/package/root_package.rs index 0807d15b..e1c4b35e 100644 --- a/crates/shirabe/src/package/root_package.rs +++ b/crates/shirabe/src/package/root_package.rs @@ -338,19 +338,19 @@ impl PackageInterface for RootPackage { fn get_stability(&self) -> &str { self.inner.get_stability() } - fn get_requires(&self) -> IndexMap<String, Link> { + fn get_requires(&self) -> std::rc::Rc<IndexMap<String, Link>> { self.inner.get_requires() } - fn get_conflicts(&self) -> IndexMap<String, Link> { + fn get_conflicts(&self) -> std::rc::Rc<IndexMap<String, Link>> { self.inner.get_conflicts() } - fn get_provides(&self) -> IndexMap<String, Link> { + fn get_provides(&self) -> std::rc::Rc<IndexMap<String, Link>> { self.inner.get_provides() } - fn get_replaces(&self) -> IndexMap<String, Link> { + fn get_replaces(&self) -> std::rc::Rc<IndexMap<String, Link>> { self.inner.get_replaces() } - fn get_dev_requires(&self) -> IndexMap<String, Link> { + fn get_dev_requires(&self) -> std::rc::Rc<IndexMap<String, Link>> { self.inner.get_dev_requires() } fn get_suggests(&self) -> IndexMap<String, String> { |
