Skip to content

Commit

Permalink
fix primitive capacity leak
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Aug 23, 2024
1 parent 65da4f3 commit c65b260
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/array/growable/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ impl<'a, T: NativeType> GrowablePrimitive<'a, T> {
#[inline]
fn to(&mut self) -> PrimitiveArray<T> {
let validity = std::mem::take(&mut self.validity);
let values = std::mem::take(&mut self.values);
let mut values = std::mem::take(&mut self.values);
values.shrink_to_fit();

PrimitiveArray::<T>::new(self.data_type.clone(), values.into(), validity.into())
}
Expand Down Expand Up @@ -100,7 +101,9 @@ impl<'a, T: NativeType> Growable<'a> for GrowablePrimitive<'a, T> {

impl<'a, T: NativeType> From<GrowablePrimitive<'a, T>> for PrimitiveArray<T> {
#[inline]
fn from(val: GrowablePrimitive<'a, T>) -> Self {
PrimitiveArray::<T>::new(val.data_type, val.values.into(), val.validity.into())
fn from(mut val: GrowablePrimitive<'a, T>) -> Self {
let mut values = std::mem::take(&mut val.values);
values.shrink_to_fit();
PrimitiveArray::<T>::new(val.data_type, values.into(), val.validity.into())
}
}

0 comments on commit c65b260

Please sign in to comment.