refactor: add arc clone lint

pull/24376/head
Edd Robinson 2021-02-15 12:40:19 +00:00
parent 2b642a8da6
commit 8a85158a98
4 changed files with 9 additions and 8 deletions

View File

@ -415,10 +415,10 @@ impl MutableBufferDb {
let mut partitions = self.partitions.write().expect("mutex poisoned");
if let Some(partition) = partitions.get(partition_key) {
partition.clone()
Arc::clone(&partition)
} else {
let partition = Arc::new(RwLock::new(Partition::new(partition_key)));
partitions.insert(partition_key.to_string(), partition.clone());
partitions.insert(partition_key.to_string(), Arc::clone(&partition));
partition
}
}

View File

@ -53,7 +53,8 @@
missing_copy_implementations,
missing_debug_implementations,
clippy::explicit_iter_loop,
clippy::use_self
clippy::use_self,
clippy::clone_on_ref_ptr
)]
pub mod chunk;

View File

@ -119,7 +119,7 @@ impl Partition {
let mut chunks: Vec<_> = self
.closed_chunks
.iter()
.map(|(_, chunk)| chunk.clone())
.map(|(_, chunk)| Arc::clone(&chunk))
.collect::<Vec<_>>();
chunks.push(self.open_chunk_snapshot());
@ -131,7 +131,7 @@ impl Partition {
/// subsequent writes.
pub fn get_chunk(&self, chunk_id: u32) -> Result<Arc<Chunk>> {
if let Some(chunk) = self.closed_chunks.get(&chunk_id) {
Ok(chunk.clone())
Ok(Arc::clone(&chunk))
} else if chunk_id == self.open_chunk.id {
Ok(self.open_chunk_snapshot())
} else {
@ -168,7 +168,7 @@ impl Partition {
chunk.mark_closed();
let chunk = Arc::new(chunk);
if !chunk.is_empty() {
let existing_value = self.closed_chunks.insert(chunk.id(), chunk.clone());
let existing_value = self.closed_chunks.insert(chunk.id(), Arc::clone(&chunk));
assert!(existing_value.is_none());
}
chunk

View File

@ -1179,7 +1179,7 @@ fn reorder_prefix(
let mut new_tag_columns = prefix_map
.iter()
.map(|&i| tag_columns[i].clone())
.map(|&i| Arc::clone(&tag_columns[i]))
.collect::<Vec<_>>();
new_tag_columns.extend(tag_columns.into_iter().enumerate().filter_map(|(i, c)| {
@ -1294,7 +1294,7 @@ impl AggExprs {
)?);
field_list.push((
field_name.clone(), // value name
Arc::clone(field_name), // value name
time_column_name,
));
}