mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-07-26 16:08:13 +00:00
refactor: clean perf related
- use array instead of vec when it's useless clippy lint message: useless use of `vec!` help: you can use an array directly. help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#useless_vec - call as_bytes before slicing lint message: calling `as_bytes` after slicing a string help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#sliced_string_as_bytes Signed-off-by: Gwen Lg <me@gwenlg.fr>
This commit is contained in:
+3
-3
@@ -598,7 +598,7 @@ impl ListObjectsQuery {
|
||||
Some("[") => Ok(RangeBegin::IncludingKey {
|
||||
key: String::from_utf8(
|
||||
BASE64_STANDARD
|
||||
.decode(token[1..].as_bytes())
|
||||
.decode(&token.as_bytes()[1..])
|
||||
.ok_or_bad_request("Invalid continuation token")?,
|
||||
)?,
|
||||
fallback_key: None,
|
||||
@@ -606,7 +606,7 @@ impl ListObjectsQuery {
|
||||
Some("]") => Ok(RangeBegin::AfterKey {
|
||||
key: String::from_utf8(
|
||||
BASE64_STANDARD
|
||||
.decode(token[1..].as_bytes())
|
||||
.decode(&token.as_bytes()[1..])
|
||||
.ok_or_bad_request("Invalid continuation token")?,
|
||||
)?,
|
||||
}),
|
||||
@@ -1043,7 +1043,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_extract_upload() {
|
||||
let objs = vec![
|
||||
let objs = [
|
||||
Object::new(
|
||||
bucket(),
|
||||
"b".to_string(),
|
||||
|
||||
+1
-1
@@ -668,7 +668,7 @@ pub(crate) fn extract_metadata_headers(
|
||||
let mut ret = Vec::new();
|
||||
|
||||
// Preserve standard headers
|
||||
let standard_header = vec![
|
||||
let standard_header = [
|
||||
hyper::header::CONTENT_TYPE,
|
||||
hyper::header::CACHE_CONTROL,
|
||||
hyper::header::CONTENT_DISPOSITION,
|
||||
|
||||
@@ -173,7 +173,7 @@ impl BlockManager {
|
||||
data_fsync: config.data_fsync,
|
||||
disable_scrub: config.disable_scrub,
|
||||
compression_level: config.compression_level,
|
||||
mutation_lock: vec![(); MUTEX_COUNT]
|
||||
mutation_lock: [(); MUTEX_COUNT]
|
||||
.iter()
|
||||
.map(|_| Mutex::new(BlockManagerLocked()))
|
||||
.collect::<Vec<_>>(),
|
||||
|
||||
@@ -314,7 +314,7 @@ async fn test_multipart_with_checksum() {
|
||||
.build();
|
||||
|
||||
let expected_checksum = calculate_sha1(
|
||||
&vec![
|
||||
&[
|
||||
BASE64_STANDARD.decode(&ck1).unwrap(),
|
||||
BASE64_STANDARD.decode(&ck2).unwrap(),
|
||||
BASE64_STANDARD.decode(&ck3).unwrap(),
|
||||
|
||||
@@ -19,7 +19,7 @@ async fn test_ssec_object() {
|
||||
.map(|x| ((x * 3792) % 256) as u8)
|
||||
.collect::<Vec<u8>>();
|
||||
|
||||
for data in vec![bytes1, bytes2] {
|
||||
for data in [bytes1, bytes2] {
|
||||
let stream = ByteStream::new(data.clone().into());
|
||||
|
||||
// Write encrypted object
|
||||
|
||||
Reference in New Issue
Block a user