Skip to content

Commit

Permalink
perf[rust]: use vec![value;n] for ChunkedArray::full (#4435)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Aug 16, 2022
1 parent 6f78893 commit 81693c6
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions polars/polars-core/src/chunked_array/ops/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@ use polars_arrow::array::default_arrays::FromData;

use crate::chunked_array::builder::get_list_builder;
use crate::prelude::*;
use crate::utils::NoNull;

impl<T> ChunkFull<T::Native> for ChunkedArray<T>
where
T: PolarsNumericType,
{
fn full(name: &str, value: T::Native, length: usize) -> Self {
let mut ca = (0..length)
.map(|_| value)
.collect::<NoNull<ChunkedArray<T>>>()
.into_inner();
ca.rename(name);
ca
let data = vec![value; length];
ChunkedArray::from_vec(name, data)
}
}

Expand Down

0 comments on commit 81693c6

Please sign in to comment.