chore: Avoid using the external library Itertools

This commit is contained in:
Clément Renault 2018-11-30 14:32:29 +01:00
parent 2719f1ad3b
commit 5829d08bc0
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE
2 changed files with 6 additions and 6 deletions

View File

@ -8,7 +8,6 @@ authors = ["Kerollmops <renault.cle@gmail.com>"]
bincode = "1.0" bincode = "1.0"
byteorder = "1.2" byteorder = "1.2"
fnv = "1.0" fnv = "1.0"
itertools = "0.7"
lazy_static = "1.1" lazy_static = "1.1"
linked-hash-map = { version = "0.5", features = ["serde_impl"] } linked-hash-map = { version = "0.5", features = ["serde_impl"] }
sdset = "0.3" sdset = "0.3"

View File

@ -2,7 +2,6 @@ use std::error::Error;
use fst::{IntoStreamer, Streamer}; use fst::{IntoStreamer, Streamer};
use group_by::GroupBy; use group_by::GroupBy;
use itertools::{Itertools, Either};
use sdset::duo::DifferenceByKey; use sdset::duo::DifferenceByKey;
use sdset::{Set, SetOperation}; use sdset::{Set, SetOperation};
@ -47,7 +46,9 @@ impl OpBuilder {
pub fn merge(self) -> Result<PositiveBlob, Box<Error>> { pub fn merge(self) -> Result<PositiveBlob, Box<Error>> {
let groups = GroupBy::new(&self.blobs, blob_same_sign); let groups = GroupBy::new(&self.blobs, blob_same_sign);
let (positives, negatives): (Vec<_>, Vec<_>) = groups.partition_map(|blobs| { let mut positives = Vec::new();
let mut negatives = Vec::new();
for blobs in groups {
match blobs[0].sign() { match blobs[0].sign() {
Sign::Positive => { Sign::Positive => {
let mut op_builder = positive::OpBuilder::with_capacity(blobs.len()); let mut op_builder = positive::OpBuilder::with_capacity(blobs.len());
@ -65,7 +66,7 @@ impl OpBuilder {
} }
let (map, doc_indexes) = builder.into_inner().unwrap(); let (map, doc_indexes) = builder.into_inner().unwrap();
let blob = PositiveBlob::from_bytes(map, doc_indexes).unwrap(); let blob = PositiveBlob::from_bytes(map, doc_indexes).unwrap();
Either::Left(blob) positives.push(blob);
}, },
Sign::Negative => { Sign::Negative => {
let mut op_builder = negative::OpBuilder::with_capacity(blobs.len()); let mut op_builder = negative::OpBuilder::with_capacity(blobs.len());
@ -73,10 +74,10 @@ impl OpBuilder {
op_builder.push(unwrap_negative(blob)); op_builder.push(unwrap_negative(blob));
} }
let blob = op_builder.union().into_negative_blob(); let blob = op_builder.union().into_negative_blob();
Either::Right(blob) negatives.push(blob);
}, },
} }
}); }
let mut zipped = positives.into_iter().zip(negatives); let mut zipped = positives.into_iter().zip(negatives);
let mut buffer = Vec::new(); let mut buffer = Vec::new();