From ec59e896c6cf405a0e52392ebb8619f26a367968 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 21 Apr 2020 17:08:42 +0000 Subject: Make UUID & Hash Copy and remove some .clone() noise --- src/api_server.rs | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src/api_server.rs') diff --git a/src/api_server.rs b/src/api_server.rs index 4ee28f57..f4bb4177 100644 --- a/src/api_server.rs +++ b/src/api_server.rs @@ -123,7 +123,7 @@ async fn handle_put( versions: Vec::new(), }; object.versions.push(Box::new(ObjectVersion { - uuid: version_uuid.clone(), + uuid: version_uuid, timestamp: now_msec(), mime_type: mime_type.to_string(), size: first_block.len() as u64, @@ -139,7 +139,7 @@ async fn handle_put( } let version = Version { - uuid: version_uuid.clone(), + uuid: version_uuid, deleted: false, blocks: Vec::new(), bucket: bucket.into(), @@ -147,12 +147,11 @@ async fn handle_put( }; let first_block_hash = hash(&first_block[..]); - object.versions[0].data = ObjectVersionData::FirstBlock(first_block_hash.clone()); + object.versions[0].data = ObjectVersionData::FirstBlock(first_block_hash); garage.object_table.insert(&object).await?; let mut next_offset = first_block.len(); - let mut put_curr_version_block = - put_block_meta(garage.clone(), &version, 0, first_block_hash.clone()); + let mut put_curr_version_block = put_block_meta(garage.clone(), &version, 0, first_block_hash); let mut put_curr_block = garage .block_manager .rpc_put_block(first_block_hash, first_block); @@ -163,12 +162,8 @@ async fn handle_put( if let Some(block) = next_block { let block_hash = hash(&block[..]); let block_len = block.len(); - put_curr_version_block = put_block_meta( - garage.clone(), - &version, - next_offset as u64, - block_hash.clone(), - ); + put_curr_version_block = + put_block_meta(garage.clone(), &version, next_offset as u64, block_hash); put_curr_block = garage.block_manager.rpc_put_block(block_hash, block); next_offset += block_len; } else { @@ -191,14 +186,11 @@ async fn put_block_meta( hash: Hash, ) -> Result<(), Error> { let mut version = version.clone(); - version.blocks.push(VersionBlock { - offset, - hash: hash.clone(), - }); + version.blocks.push(VersionBlock { offset, hash: hash }); let block_ref = BlockRef { block: hash, - version: version.uuid.clone(), + version: version.uuid, deleted: false, }; @@ -279,7 +271,7 @@ async fn handle_delete(garage: Arc, bucket: &str, key: &str) -> Result>(); blocks[0].1 = Some(first_block); -- cgit v1.2.3