Skip to content

Commit 6f542ad

Browse files
authored
Enable Clippy redundant clone check (#1361)
1 parent 18986c2 commit 6f542ad

File tree

25 files changed

+42
-46
lines changed

25 files changed

+42
-46
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ multiple_crate_versions = "allow"
206206
or_fun_call = "deny"
207207
panic_in_result_fn = "deny"
208208
panic = "deny"
209+
redundant_clone = "deny"
209210
same_name_method = "deny"
210211
tests_outside_test_module = "deny"
211212
# todo = "deny"

encodings/bytebool/src/compute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ mod tests {
144144
#[test]
145145
fn test_slice() {
146146
let original = vec![Some(true), Some(true), None, Some(false), None];
147-
let vortex_arr = ByteBoolArray::from(original.clone());
147+
let vortex_arr = ByteBoolArray::from(original);
148148

149149
let sliced_arr = slice(vortex_arr.as_ref(), 1, 4).unwrap();
150150
let sliced_arr = ByteBoolArray::try_from(sliced_arr).unwrap();

encodings/datetime-parts/src/compress.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct TemporalParts {
1717
/// cascading compression.
1818
pub fn split_temporal(array: TemporalArray) -> VortexResult<TemporalParts> {
1919
let temporal_values = array.temporal_values().into_primitive()?;
20-
let validity = temporal_values.validity().clone();
20+
let validity = temporal_values.validity();
2121

2222
// After this operation, timestamps will be non-nullable PrimitiveArray<i64>
2323
let timestamps = try_cast(

encodings/datetime-parts/src/compute.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ pub fn decode_to_temporal(array: &DateTimePartsArray) -> VortexResult<TemporalAr
122122
.collect::<Vec<_>>();
123123

124124
Ok(TemporalArray::new_timestamp(
125-
PrimitiveArray::from_vec(values, array.validity().clone()).into_array(),
125+
PrimitiveArray::from_vec(values, array.validity()).into_array(),
126126
temporal_metadata.time_unit(),
127127
temporal_metadata.time_zone().map(ToString::to_string),
128128
))
@@ -182,7 +182,7 @@ mod test {
182182
assert_eq!(validity, raw_millis.validity());
183183

184184
let date_times = DateTimePartsArray::try_new(
185-
DType::Extension(temporal_array.ext_dtype().clone()),
185+
DType::Extension(temporal_array.ext_dtype()),
186186
days,
187187
seconds,
188188
subseconds,

encodings/dict/src/compute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl MaybeCompareFn for DictArray {
4848
// Ensure the other is the same length as the dictionary
4949
slice(other, 0, self.values().len())
5050
.and_then(|other| compare(self.values(), other, operator))
51-
.and_then(|values| Self::try_new(self.codes().clone(), values))
51+
.and_then(|values| Self::try_new(self.codes(), values))
5252
.map(|a| a.into_array()),
5353
);
5454
}

encodings/runend/src/compute.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl MaybeCompareFn for RunEndArray {
5454
return Some(
5555
slice(other, 0, self.values().len())
5656
.and_then(|other| compare(self.values(), other, operator))
57-
.and_then(|values| Self::try_new(self.ends().clone(), values, self.validity()))
57+
.and_then(|values| Self::try_new(self.ends(), values, self.validity()))
5858
.map(|a| a.into_array()),
5959
);
6060
}
@@ -265,7 +265,7 @@ mod test {
265265
fn ree_null_scalar() {
266266
let array = ree_array();
267267
let null_ree = RunEndArray::try_new(
268-
array.ends().clone(),
268+
array.ends(),
269269
try_cast(array.values(), &array.values().dtype().as_nullable()).unwrap(),
270270
Validity::AllInvalid,
271271
)

encodings/zigzag/src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ mod test {
145145
assert_eq!(stats.get(stat), array.statistics().compute(stat).as_ref());
146146
}
147147

148-
let sliced = ZigZagArray::try_from(slice(zigzag.clone(), 0, 2).unwrap()).unwrap();
148+
let sliced = ZigZagArray::try_from(slice(zigzag, 0, 2).unwrap()).unwrap();
149149
assert_eq!(
150150
scalar_at(&sliced, sliced.len() - 1).unwrap(),
151151
Scalar::from(-5i32)

vortex-array/src/array/bool/compute/fill.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ impl FillForwardFn for BoolArray {
1616
}
1717
// all valid, but we need to convert to non-nullable
1818
if validity.all_valid() {
19-
return Ok(
20-
Self::new(self.boolean_buffer().clone(), Nullability::Nullable).into_array(),
21-
);
19+
return Ok(Self::new(self.boolean_buffer(), Nullability::Nullable).into_array());
2220
}
2321
// all invalid => fill with default value (false)
2422
if validity.all_invalid() {

vortex-array/src/array/bool/stats.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ impl ArrayStatisticsCompute for BoolArray {
2929
match self.logical_validity() {
3030
LogicalValidity::AllValid(_) => self.boolean_buffer().compute_statistics(stat),
3131
LogicalValidity::AllInvalid(v) => Ok(StatsSet::nulls(v, self.dtype())),
32-
LogicalValidity::Array(a) => NullableBools(
33-
&self.boolean_buffer(),
34-
&a.clone().into_bool()?.boolean_buffer(),
35-
)
36-
.compute_statistics(stat),
32+
LogicalValidity::Array(a) => {
33+
NullableBools(&self.boolean_buffer(), &a.into_bool()?.boolean_buffer())
34+
.compute_statistics(stat)
35+
}
3736
}
3837
}
3938
}

vortex-array/src/array/datetime/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ test_fail_case!(test_fail_date64, i32, TemporalArray::new_date, TimeUnit::Ms);
118118
#[test]
119119
fn test_timestamp() {
120120
let ts = PrimitiveArray::from_vec(vec![100i64], Validity::NonNullable);
121-
let ts_array = ts.clone().into_array();
121+
let ts_array = ts.into_array();
122122

123123
for unit in [TimeUnit::S, TimeUnit::Ms, TimeUnit::Us, TimeUnit::Ns] {
124124
for tz in [Some("UTC".to_string()), None] {
@@ -138,7 +138,7 @@ fn test_timestamp() {
138138
#[should_panic]
139139
fn test_timestamp_fails_i32() {
140140
let ts = PrimitiveArray::from_vec(vec![100i32], Validity::NonNullable);
141-
let ts_array = ts.clone().into_array();
141+
let ts_array = ts.into_array();
142142

143-
let _ = TemporalArray::new_timestamp(ts_array.clone(), TimeUnit::S, None);
143+
let _ = TemporalArray::new_timestamp(ts_array, TimeUnit::S, None);
144144
}

0 commit comments

Comments
 (0)