Skip to content

Commit

Permalink
slight optimization in comparison collection T::Native
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Sep 12, 2020
1 parent b4c584d commit 0d64073
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions polars/src/chunked_array/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ macro_rules! apply_operand_on_chunkedarray_by_iter {
{
match ($self.null_count(), $rhs.null_count()) {
(0, 0) => {
$self
let a: Xob<ChunkedArray<_>> = $self
.into_no_null_iter()
.zip($rhs.into_no_null_iter())
// TODO: use Xob to get rid of redundant Some<T>
.map(|(left, right)| Some(left $operand right))
.collect()
.map(|(left, right)| left $operand right)
.collect();
a.into_inner()
},
(0, _) => {
$self
Expand Down
2 changes: 1 addition & 1 deletion polars/src/chunked_array/comparison.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use crate::{prelude::*, utils::Xob};
use arrow::{
array::{ArrayRef, BooleanArray, PrimitiveArray, StringArray},
compute,
Expand Down
4 changes: 4 additions & 0 deletions polars/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ macro_rules! exec_concurrent {
}

/// Just a wrapper structure. Useful for certain impl specializations
/// This is for instance use to implement
/// `impl<T> FromIterator<T::Native> for Xob<ChunkedArray<T>>`
/// as `Option<T::Native>` was alrady implemented:
/// `impl<T> FromIterator<Option<T::Native>> for ChunkedArray<T>`
pub struct Xob<T> {
inner: T,
}
Expand Down

0 comments on commit 0d64073

Please sign in to comment.