From cd7c3fce2472656b2a1247429751e43350976677 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 19 Aug 2026 23:45:38 +0900 Subject: 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 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> 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) --- crates/shirabe/src/repository/filesystem_repository.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/shirabe/src/repository/filesystem_repository.rs') diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs index 54c2fa1f..5f06505a 100644 --- a/crates/shirabe/src/repository/filesystem_repository.rs +++ b/crates/shirabe/src/repository/filesystem_repository.rs @@ -510,7 +510,7 @@ impl FilesystemRepository { .as_array() .map(|m| m.contains_key(&package.get_name())) .unwrap_or(false); - for (_, replace) in package.get_replaces() { + for (_, replace) in package.get_replaces().iter() { // exclude platform replaces as when they are really there we can not check for their presence if PlatformRepository::is_platform_package(replace.get_target()) { continue; @@ -527,7 +527,7 @@ impl FilesystemRepository { is_dev_package, ); } - for (_, provide) in package.get_provides() { + for (_, provide) in package.get_provides().iter() { // exclude platform provides as when they are really there we can not check for their presence if PlatformRepository::is_platform_package(provide.get_target()) { continue; -- cgit v1.3.1-4-g156e