aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/plugin
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/plugin
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/plugin')
-rw-r--r--crates/shirabe/src/plugin/php_plugin_proxy.rs10
-rw-r--r--crates/shirabe/src/plugin/plugin_manager.rs4
2 files changed, 7 insertions, 7 deletions
diff --git a/crates/shirabe/src/plugin/php_plugin_proxy.rs b/crates/shirabe/src/plugin/php_plugin_proxy.rs
index 4b99f528..0cd36b18 100644
--- a/crates/shirabe/src/plugin/php_plugin_proxy.rs
+++ b/crates/shirabe/src/plugin/php_plugin_proxy.rs
@@ -2005,11 +2005,11 @@ fn dispatch_package_method(
))
}
"getStability" => Ok(PluginValue::string(package.get_stability().to_string())),
- "getRequires" => Ok(links(package.get_requires())),
- "getConflicts" => Ok(links(package.get_conflicts())),
- "getProvides" => Ok(links(package.get_provides())),
- "getReplaces" => Ok(links(package.get_replaces())),
- "getDevRequires" => Ok(links(package.get_dev_requires())),
+ "getRequires" => Ok(links((*package.get_requires()).clone())),
+ "getConflicts" => Ok(links((*package.get_conflicts()).clone())),
+ "getProvides" => Ok(links((*package.get_provides()).clone())),
+ "getReplaces" => Ok(links((*package.get_replaces()).clone())),
+ "getDevRequires" => Ok(links((*package.get_dev_requires()).clone())),
"getSuggests" => {
let suggests = package.get_suggests();
if suggests.is_empty() {
diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs
index 2fff2d74..1ecb4153 100644
--- a/crates/shirabe/src/plugin/plugin_manager.rs
+++ b/crates/shirabe/src/plugin/plugin_manager.rs
@@ -224,7 +224,7 @@ impl PluginManager {
if package.get_type() == "composer-plugin" {
let requires_map = package.get_requires();
let mut requires_composer: Option<&shirabe_semver::constraint::AnyConstraint> = None;
- for (_k, link) in &requires_map {
+ for (_k, link) in requires_map.iter() {
if "composer-plugin-api" == link.get_target() {
requires_composer = Some(link.get_constraint());
break;
@@ -951,7 +951,7 @@ impl PluginManager {
package: PackageInterfaceHandle,
) -> anyhow::Result<IndexMap<String, PackageInterfaceHandle>> {
// TODO(plugin): used by registerPackage to assemble plugin dependency autoload map
- for (_k, require_link) in &package.get_requires() {
+ for (_k, require_link) in package.get_requires().iter() {
for required_package in installed_repo
.find_packages_with_replacers_and_providers(require_link.get_target(), None)?
{