aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/installer.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/installer.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/installer.rs')
-rw-r--r--crates/shirabe/src/installer.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs
index ee60f59f..d1e38542 100644
--- a/crates/shirabe/src/installer.rs
+++ b/crates/shirabe/src/installer.rs
@@ -1082,13 +1082,13 @@ impl Installer {
request.fix_locked_package(package.clone());
}
- let mut root_requires = self.package.get_requires();
+ let mut root_requires = (*self.package.get_requires()).clone();
if self.dev_mode {
- for (k, v) in self.package.get_dev_requires() {
- root_requires.insert(k, v);
+ for (k, v) in self.package.get_dev_requires().iter() {
+ root_requires.insert(k.clone(), v.clone());
}
}
- for (_key, link) in &root_requires {
+ for (_key, link) in root_requires.iter() {
if PlatformRepository::is_platform_package(link.get_target()) {
request.require_name(link.get_target(), Some(link.get_constraint().clone()))?;
}
@@ -1331,11 +1331,11 @@ impl Installer {
// Convert Link map merge into ConstraintInterface map for use later
let mut req_links: IndexMap<String, Link> = IndexMap::new();
- for (k, v) in self.package.get_requires() {
- req_links.insert(k, v);
+ for (k, v) in self.package.get_requires().iter() {
+ req_links.insert(k.clone(), v.clone());
}
- for (k, v) in self.package.get_dev_requires() {
- req_links.insert(k, v);
+ for (k, v) in self.package.get_dev_requires().iter() {
+ req_links.insert(k.clone(), v.clone());
}
// Translate to constraint map for downstream uniform handling.
let mut tmp: IndexMap<String, AnyConstraint> = IndexMap::new();
@@ -1579,13 +1579,13 @@ impl Installer {
}
}
} else {
- let mut links = self.package.get_requires();
+ let mut links = (*self.package.get_requires()).clone();
if include_dev_requires {
- for (k, v) in self.package.get_dev_requires() {
- links.insert(k, v);
+ for (k, v) in self.package.get_dev_requires().iter() {
+ links.insert(k.clone(), v.clone());
}
}
- for (_key, link) in &links {
+ for (_key, link) in links.iter() {
request.require_name(link.get_target(), Some(link.get_constraint().clone()))?;
}
}