aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/update_command.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/command/update_command.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/command/update_command.rs')
-rw-r--r--crates/shirabe/src/command/update_command.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs
index 0548fc02..09809eb2 100644
--- a/crates/shirabe/src/command/update_command.rs
+++ b/crates/shirabe/src/command/update_command.rs
@@ -83,8 +83,8 @@ impl UpdateCommand {
let platform_req_filter = self.get_platform_requirement_filter(input);
let stability_flags = composer_ref.get_package().get_stability_flags();
let requires = array_merge_map(
- composer_ref.get_package().get_requires(),
- composer_ref.get_package().get_dev_requires(),
+ (*composer_ref.get_package().get_requires()).clone(),
+ (*composer_ref.get_package().get_dev_requires()).clone(),
);
let filter: Option<String> = if !packages.is_empty() {
@@ -156,7 +156,7 @@ impl UpdateCommand {
}
}
if installed_packages.is_empty() {
- for (req, _constraint) in &requires {
+ for (req, _constraint) in requires.iter() {
if PlatformRepository::is_platform_package(req) {
continue;
}
@@ -401,9 +401,11 @@ impl Command for UpdateCommand {
let parser = VersionParser::new();
let mut temporary_constraints: IndexMap<String, _> = IndexMap::new();
- let root_requirements =
- array_merge_map(root_package.get_requires(), root_package.get_dev_requires());
- for (package, constraint) in &reqs {
+ let root_requirements = array_merge_map(
+ (*root_package.get_requires()).clone(),
+ (*root_package.get_dev_requires()).clone(),
+ );
+ for (package, constraint) in reqs.iter() {
let package = strtolower(package);
let parsed_constraint = parser.parse_constraints(constraint)?;
temporary_constraints.insert(package.clone(), parsed_constraint.clone());