aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/repository_utils.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-19 23:45:38 +0900
committernsfisis <nsfisis@gmail.com>2026-08-19 23:45:38 +0900
commitcd7c3fce2472656b2a1247429751e43350976677 (patch)
tree95e8760e3417fc3e63dac28bc0cd823a6af768f2 /crates/shirabe/src/repository/repository_utils.rs
parentb8fb046bd7c4cd28598bcce9f3955d834ea5d008 (diff)
downloadphp-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/repository/repository_utils.rs')
-rw-r--r--crates/shirabe/src/repository/repository_utils.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/shirabe/src/repository/repository_utils.rs b/crates/shirabe/src/repository/repository_utils.rs
index c2997f31..3df86b05 100644
--- a/crates/shirabe/src/repository/repository_utils.rs
+++ b/crates/shirabe/src/repository/repository_utils.rs
@@ -16,9 +16,14 @@ impl RepositoryUtils {
include_require_dev: bool,
mut bucket: Vec<crate::package::BasePackageHandle>,
) -> Vec<crate::package::BasePackageHandle> {
- let mut requires: IndexMap<String, Link> = requirer.get_requires();
+ let mut requires: IndexMap<String, Link> = (*requirer.get_requires()).clone();
if include_require_dev {
- requires.extend(requirer.get_dev_requires());
+ requires.extend(
+ requirer
+ .get_dev_requires()
+ .iter()
+ .map(|(k, v)| (k.clone(), v.clone())),
+ );
}
for candidate in packages {