diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-20 18:34:54 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-20 18:34:54 +0900 |
| commit | 81b9fc9d92bb74aa8428ae4db39bd84e8c16095c (patch) | |
| tree | 3efb6476d797e2a95545c4c3abba468c3e3c8d52 /crates/shirabe/src/repository/vcs/vcs_driver.rs | |
| parent | c09cd630afb4bb0ca10e926f93bf706ca828ae85 (diff) | |
| download | php-shirabe-81b9fc9d92bb74aa8428ae4db39bd84e8c16095c.tar.gz php-shirabe-81b9fc9d92bb74aa8428ae4db39bd84e8c16095c.tar.zst php-shirabe-81b9fc9d92bb74aa8428ae4db39bd84e8c16095c.zip | |
refactor(php-shim): drop Box wrapping from PhpMixed List/Array
The List and Array variants of PhpMixed boxed their elements
unnecessarily. Store PhpMixed values directly and update all callers
accordingly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository/vcs/vcs_driver.rs')
| -rw-r--r-- | crates/shirabe/src/repository/vcs/vcs_driver.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs index ac7496d..249e53f 100644 --- a/crates/shirabe/src/repository/vcs/vcs_driver.rs +++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs @@ -75,7 +75,7 @@ impl VcsDriverBase { .cloned() .unwrap_or(PhpMixed::Array(IndexMap::new())); let options: IndexMap<String, PhpMixed> = match options_mixed { - PhpMixed::Array(a) => a.into_iter().map(|(k, v)| (k, *v)).collect(), + PhpMixed::Array(a) => a, _ => IndexMap::new(), }; self.http_downloader @@ -114,10 +114,7 @@ impl VcsDriverBase { _ => return Ok(None), }; - // PHP arrays own their nested values; the Rust representation wraps them - // in Box<PhpMixed>. Unbox the outer level so callers can mutate keys. - let mut composer: IndexMap<String, PhpMixed> = - array.into_iter().map(|(k, v)| (k, *v)).collect(); + let mut composer: IndexMap<String, PhpMixed> = array; if (!composer.contains_key("time") || composer @@ -153,9 +150,7 @@ impl VcsDriverBase { && let Some(res) = self.cache.as_mut().and_then(|c| c.read(identifier)) { let parsed = JsonFile::parse_json(Some(&res), None)?; - let composer: Option<IndexMap<String, PhpMixed>> = parsed - .as_array() - .map(|m| m.iter().map(|(k, v)| (k.clone(), (**v).clone())).collect()); + let composer: Option<IndexMap<String, PhpMixed>> = parsed.as_array().map(|m| m.clone()); self.info_cache .insert(identifier.to_string(), composer.clone()); return Ok(Some(composer)); @@ -219,7 +214,7 @@ pub trait VcsDriver: VcsDriverInterface { { let parsed = JsonFile::parse_json(Some(&res), None)?; let parsed_map: Option<IndexMap<String, PhpMixed>> = match parsed { - PhpMixed::Array(a) => Some(a.into_iter().map(|(k, v)| (k, *v)).collect()), + PhpMixed::Array(a) => Some(a), _ => None, }; self.info_cache_mut() @@ -235,7 +230,7 @@ pub trait VcsDriver: VcsDriverInterface { let composer_mixed = PhpMixed::Array( composer_map .iter() - .map(|(k, v)| (k.clone(), Box::new(v.clone()))) + .map(|(k, v)| (k.clone(), v.clone())) .collect(), ); let encoded = JsonFile::encode_with_options( @@ -273,7 +268,7 @@ pub trait VcsDriver: VcsDriverInterface { )?; let mut composer: IndexMap<String, PhpMixed> = match composer { - PhpMixed::Array(a) if !a.is_empty() => a.into_iter().map(|(k, v)| (k, *v)).collect(), + PhpMixed::Array(a) if !a.is_empty() => a, _ => return Ok(None), }; @@ -313,7 +308,7 @@ pub trait VcsDriver: VcsDriverInterface { .cloned() .unwrap_or(PhpMixed::Array(IndexMap::new())); let options: IndexMap<String, PhpMixed> = match options_mixed { - PhpMixed::Array(a) => a.into_iter().map(|(k, v)| (k, *v)).collect(), + PhpMixed::Array(a) => a, _ => IndexMap::new(), }; self.http_downloader() |
