aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/util
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-25 16:16:33 +0900
committernsfisis <nsfisis@gmail.com>2026-07-25 16:17:10 +0900
commit432472808051cb4f1bb9517b858dbc810aaa5a63 (patch)
tree4c58b97942853ea2c3f58368203fa93187746cf8 /crates/shirabe/src/util
parentd4608662f28b9a5135986b1702afe3199957eabe (diff)
downloadphp-shirabe-432472808051cb4f1bb9517b858dbc810aaa5a63.tar.gz
php-shirabe-432472808051cb4f1bb9517b858dbc810aaa5a63.tar.zst
php-shirabe-432472808051cb4f1bb9517b858dbc810aaa5a63.zip
refactor: replace redundant clones with moves
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/util')
-rw-r--r--crates/shirabe/src/util/config_validator.rs2
-rw-r--r--crates/shirabe/src/util/forgejo.rs10
-rw-r--r--crates/shirabe/src/util/forgejo_url.rs2
-rw-r--r--crates/shirabe/src/util/git.rs3
-rw-r--r--crates/shirabe/src/util/github.rs5
-rw-r--r--crates/shirabe/src/util/http/curl_downloader.rs2
-rw-r--r--crates/shirabe/src/util/http_downloader.rs8
-rw-r--r--crates/shirabe/src/util/perforce.rs2
-rw-r--r--crates/shirabe/src/util/process_executor.rs4
-rw-r--r--crates/shirabe/src/util/remote_filesystem.rs2
-rw-r--r--crates/shirabe/src/util/svn.rs2
-rw-r--r--crates/shirabe/src/util/tls_helper.rs2
-rw-r--r--crates/shirabe/src/util/url.rs6
13 files changed, 18 insertions, 32 deletions
diff --git a/crates/shirabe/src/util/config_validator.rs b/crates/shirabe/src/util/config_validator.rs
index a9b89fd6..626c4db1 100644
--- a/crates/shirabe/src/util/config_validator.rs
+++ b/crates/shirabe/src/util/config_validator.rs
@@ -292,7 +292,7 @@ impl ConfigValidator {
None,
array_loader_validation_flags,
);
- let mut manifest_for_load = manifest.clone();
+ let mut manifest_for_load = manifest;
if !manifest_for_load.contains_key("version") {
manifest_for_load.insert("version".to_string(), PhpMixed::String("1.0.0".to_string()));
}
diff --git a/crates/shirabe/src/util/forgejo.rs b/crates/shirabe/src/util/forgejo.rs
index 3a51be52..41d0dd3d 100644
--- a/crates/shirabe/src/util/forgejo.rs
+++ b/crates/shirabe/src/util/forgejo.rs
@@ -46,10 +46,8 @@ impl Forgejo {
self.io.write_error3(&url, true, io_interface::NORMAL);
let (local_auth_name, has_local_auth, auth_name): (String, bool, String) = {
let cfg = self.config.borrow();
- let local = cfg
- .get_local_auth_config_source()
- .map(|s| s.get_name().to_string());
- let auth = cfg.get_auth_config_source().get_name().to_string();
+ let local = cfg.get_local_auth_config_source().map(|s| s.get_name());
+ let auth = cfg.get_auth_config_source().get_name();
(local.clone().unwrap_or_default(), local.is_some(), auth)
};
let local_prefix = if has_local_auth {
@@ -150,8 +148,8 @@ impl Forgejo {
.remove_config_setting(&setting_key)?;
}
let value = shirabe_php_shim::PhpMixed::Array(indexmap::indexmap! {
- "username".to_string() => username.clone().into(),
- "token".to_string() => token.clone().into(),
+ "username".to_string() => username.into(),
+ "token".to_string() => token.into(),
});
if store_in_local_auth_config && has_local_auth {
let mut cfg = self.config.borrow_mut();
diff --git a/crates/shirabe/src/util/forgejo_url.rs b/crates/shirabe/src/util/forgejo_url.rs
index 157ea53e..ce5a8948 100644
--- a/crates/shirabe/src/util/forgejo_url.rs
+++ b/crates/shirabe/src/util/forgejo_url.rs
@@ -65,7 +65,7 @@ impl ForgejoUrl {
Some(Self::new(
m[3].clone(),
m[4].clone(),
- origin_url.clone(),
+ origin_url,
format!("https://{}/repos/{}/{}", api_base, m[3], m[4]),
))
}
diff --git a/crates/shirabe/src/util/git.rs b/crates/shirabe/src/util/git.rs
index 6a6aaeb1..3e650fd1 100644
--- a/crates/shirabe/src/util/git.rs
+++ b/crates/shirabe/src/util/git.rs
@@ -243,7 +243,7 @@ impl Git {
let m3 = m.get(&CaptureKey::ByIndex(3)).cloned().unwrap_or_default();
if !self.io.has_authentication(&m3) {
self.io.borrow_mut().set_authentication(
- m3.clone(),
+ m3,
rawurldecode(&m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default()),
Some(rawurldecode(
&m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default(),
@@ -701,7 +701,6 @@ impl Git {
.ask(
" Username: ".to_string(),
default_username
- .clone()
.map(PhpMixed::String)
.unwrap_or(PhpMixed::Null),
)
diff --git a/crates/shirabe/src/util/github.rs b/crates/shirabe/src/util/github.rs
index e6bac7ec..0afbb684 100644
--- a/crates/shirabe/src/util/github.rs
+++ b/crates/shirabe/src/util/github.rs
@@ -114,9 +114,8 @@ impl GitHub {
let (local_name, auth_name): (Option<String>, String) = {
let cfg = self.config.borrow();
(
- cfg.get_local_auth_config_source()
- .map(|c| c.get_name().to_string()),
- cfg.get_auth_config_source().get_name().to_string(),
+ cfg.get_local_auth_config_source().map(|c| c.get_name()),
+ cfg.get_auth_config_source().get_name(),
)
};
let prefix = local_name
diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs
index 508aa56e..3b65b0f6 100644
--- a/crates/shirabe/src/util/http/curl_downloader.rs
+++ b/crates/shirabe/src/util/http/curl_downloader.rs
@@ -644,7 +644,7 @@ impl CurlDownloader {
{
if !parse_url(&location_header, shirabe_php_shim::PHP_URL_SCHEME).is_null() {
// Absolute URL; e.g. https://example.com/composer
- target_url = location_header.clone();
+ target_url = location_header;
} else if !parse_url(&location_header, shirabe_php_shim::PHP_URL_HOST).is_null() {
// Scheme relative; e.g. //example.com/foo
target_url = format!(
diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs
index 0c91484d..2346c351 100644
--- a/crates/shirabe/src/util/http_downloader.rs
+++ b/crates/shirabe/src/util/http_downloader.rs
@@ -126,13 +126,7 @@ impl HttpDownloader {
};
let rfs = Some(std::rc::Rc::new(std::cell::RefCell::new(
- RemoteFilesystem::new(
- io.clone(),
- config.clone(),
- options.clone(),
- disable_tls,
- None,
- ),
+ RemoteFilesystem::new(io.clone(), config.clone(), options, disable_tls, None),
)));
let mut max_jobs: i64 = 12;
diff --git a/crates/shirabe/src/util/perforce.rs b/crates/shirabe/src/util/perforce.rs
index e39ed3c2..fa448b35 100644
--- a/crates/shirabe/src/util/perforce.rs
+++ b/crates/shirabe/src/util/perforce.rs
@@ -294,7 +294,7 @@ impl Perforce {
let field1 = fields.get(1).cloned().unwrap_or_default();
let index = strpos(&field1, " ");
let value = match index {
- None => field1.clone(),
+ None => field1,
Some(idx) => substr(&field1, 0, Some(idx as i64)),
};
let value = trim(&value, None);
diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs
index 1f167840..738da143 100644
--- a/crates/shirabe/src/util/process_executor.rs
+++ b/crates/shirabe/src/util/process_executor.rs
@@ -231,7 +231,7 @@ impl ProcessExecutor {
process = Process::from_shell_commandline(
&command_str,
cwd,
- env.clone(),
+ env,
PhpMixed::Null,
Some(Self::get_timeout() as f64),
)?;
@@ -419,7 +419,7 @@ impl ProcessExecutor {
};
let mut mock = self.mock.as_ref().unwrap().borrow_mut();
- mock.log.push(command_string.clone());
+ mock.log.push(command_string);
let matched = mock
.expectations
diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs
index 103a94a7..a244c9f9 100644
--- a/crates/shirabe/src/util/remote_filesystem.rs
+++ b/crates/shirabe/src/util/remote_filesystem.rs
@@ -284,7 +284,7 @@ impl RemoteFilesystem {
} else {
"Reading "
},
- Url::sanitize(orig_file_url.clone()),
+ Url::sanitize(orig_file_url),
using_proxy
),
true,
diff --git a/crates/shirabe/src/util/svn.rs b/crates/shirabe/src/util/svn.rs
index f761ac05..67501e5a 100644
--- a/crates/shirabe/src/util/svn.rs
+++ b/crates/shirabe/src/util/svn.rs
@@ -168,7 +168,7 @@ impl Svn {
let error_output = self.process.borrow().get_error_output().to_string();
let full_output = trim(
- &implode("\n", &[output.clone().unwrap_or_default(), error_output]),
+ &implode("\n", &[output.unwrap_or_default(), error_output]),
None,
);
diff --git a/crates/shirabe/src/util/tls_helper.rs b/crates/shirabe/src/util/tls_helper.rs
index 5121bd06..30d5f754 100644
--- a/crates/shirabe/src/util/tls_helper.rs
+++ b/crates/shirabe/src/util/tls_helper.rs
@@ -44,7 +44,7 @@ impl TlsHelper {
if let Some(matcher) = matcher
&& matcher(&hostname)
{
- *cn = Some(names.cn.clone());
+ *cn = Some(names.cn);
return true;
}
diff --git a/crates/shirabe/src/util/url.rs b/crates/shirabe/src/util/url.rs
index 77649308..621f6fab 100644
--- a/crates/shirabe/src/util/url.rs
+++ b/crates/shirabe/src/util/url.rs
@@ -103,11 +103,7 @@ impl Url {
&format!("$1/{}", r#ref),
&url,
);
- } else if in_array(
- PhpMixed::String(host.clone()),
- &config.get("gitlab-domains"),
- true,
- ) {
+ } else if in_array(PhpMixed::String(host), &config.get("gitlab-domains"), true) {
url = Preg::replace(
php_regex!(
r"{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i"