Skip to content

Commit d5ab2c0

Browse files
authored
StructArray::try_new doesn't force fields copy (#2281)
1 parent a4f00e3 commit d5ab2c0

File tree

1 file changed

+3
-5
lines changed
  • vortex-array/src/array/struct_

1 file changed

+3
-5
lines changed

vortex-array/src/array/struct_/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl StructArray {
5858

5959
pub fn try_new(
6060
names: FieldNames,
61-
fields: Vec<Array>,
61+
mut fields: Vec<Array>,
6262
length: usize,
6363
validity: Validity,
6464
) -> VortexResult<Self> {
@@ -81,10 +81,8 @@ impl StructArray {
8181

8282
let validity_metadata = validity.to_metadata(length)?;
8383

84-
let mut children = Vec::with_capacity(fields.len() + 1);
85-
children.extend(fields);
8684
if let Some(v) = validity.into_array() {
87-
children.push(v);
85+
fields.push(v);
8886
}
8987

9088
Self::try_from_parts(
@@ -94,7 +92,7 @@ impl StructArray {
9492
validity: validity_metadata,
9593
}),
9694
None,
97-
Some(children.into()),
95+
Some(fields.into()),
9896
StatsSet::default(),
9997
)
10098
}

0 commit comments

Comments
 (0)