Skip to content

Commit

Permalink
Avoid a Box::new() when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
judahrand committed Jun 12, 2024
1 parent 86fb18f commit bb71c48
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions arrow-select/src/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,24 @@ fn binary_capacity<T: ByteArrayType>(arrays: &[&dyn Array]) -> Capacities {
fn fixed_size_list_capacity(arrays: &[&dyn Array], data_type: &DataType) -> Capacities {
if let DataType::FixedSizeList(f, _) = data_type {
let item_capacity = arrays.iter().map(|a| a.len()).sum();
let values: Vec<&dyn arrow_array::Array> = arrays
.iter()
.map(|a| a.as_fixed_size_list().values().as_ref())
.collect();
Capacities::List(
item_capacity,
Some(Box::new(get_capacity(&values, f.data_type()))),
)
let child_data_type = f.data_type();
match child_data_type {
DataType::Utf8
| DataType::LargeUtf8
| DataType::Binary
| DataType::LargeBinary
| DataType::FixedSizeList(_, _) => {
let values: Vec<&dyn arrow_array::Array> = arrays
.iter()
.map(|a| a.as_fixed_size_list().values().as_ref())
.collect();
Capacities::List(
item_capacity,
Some(Box::new(get_capacity(&values, child_data_type))),
)
},
_ => Capacities::Array(item_capacity),
}
} else {
unreachable!("illegal data type for fixed size list")
}
Expand Down

0 comments on commit bb71c48

Please sign in to comment.