mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-24 11:36:31 +00:00
fix: remove func call from alternative value.
this avoid useless allocation or non-trivial work, if the default value is not needed/used. add a line in Cargo.toml to easly enable or_fun_call lint help: https://rust-lang.github.io/rust-clippy/master/index.html?search=or_fun_call
This commit is contained in:
@@ -62,7 +62,7 @@ impl Endpoint {
|
||||
let (bucket, partition_key) = path
|
||||
.split_once('/')
|
||||
.map(|(b, p)| (b.to_owned(), p.trim_start_matches('/')))
|
||||
.unwrap_or((path.to_owned(), ""));
|
||||
.unwrap_or_else(|| (path.to_owned(), ""));
|
||||
|
||||
if bucket.is_empty() {
|
||||
return Err(Error::bad_request("Missing bucket name"));
|
||||
|
||||
@@ -494,7 +494,7 @@ pub async fn handle_complete_multipart_upload(
|
||||
.root_domain
|
||||
.as_ref()
|
||||
.map(|rd| s3_xml::Value(format!("https://{}.{}/{}", bucket_name, rd, key)))
|
||||
.or(Some(s3_xml::Value(format!("/{}/{}", bucket_name, key)))),
|
||||
.or_else(|| Some(s3_xml::Value(format!("/{}/{}", bucket_name, key)))),
|
||||
bucket: s3_xml::Value(bucket_name.to_string()),
|
||||
key: s3_xml::Value(key),
|
||||
etag: s3_xml::Value(format!("\"{}\"", etag)),
|
||||
|
||||
@@ -330,7 +330,7 @@ impl Endpoint {
|
||||
} else {
|
||||
path.split_once('/')
|
||||
.map(|(b, p)| (b.to_owned(), p.trim_start_matches('/')))
|
||||
.unwrap_or((path.to_owned(), ""))
|
||||
.unwrap_or_else(|| (path.to_owned(), ""))
|
||||
};
|
||||
|
||||
if *req.method() == Method::OPTIONS {
|
||||
|
||||
Reference in New Issue
Block a user