refactor: Prefer match on the result of cmp to if/else if/else chains
parent
1247544deb
commit
2eb09f29ef
|
@ -1,6 +1,5 @@
|
||||||
#![deny(rust_2018_idioms)]
|
#![deny(rust_2018_idioms)]
|
||||||
#![warn(clippy::explicit_iter_loop)]
|
#![warn(clippy::explicit_iter_loop)]
|
||||||
#![allow(clippy::comparison_chain)]
|
|
||||||
|
|
||||||
use std::{error, fmt};
|
use std::{error, fmt};
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ use crate::storage::series_store::ReadPoint;
|
||||||
use crate::storage::StorageError;
|
use crate::storage::StorageError;
|
||||||
|
|
||||||
use futures::stream::{BoxStream, Stream};
|
use futures::stream::{BoxStream, Stream};
|
||||||
|
use std::cmp::Ordering;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
@ -125,14 +126,16 @@ impl Stream for StringMergeStream<'_> {
|
||||||
next_val = Some(val.clone());
|
next_val = Some(val.clone());
|
||||||
next_pos = pos;
|
next_pos = pos;
|
||||||
}
|
}
|
||||||
(Some(next), Poll::Ready(Some(ref val))) => {
|
(Some(next), Poll::Ready(Some(ref val))) => match next.cmp(val) {
|
||||||
if next > val {
|
Ordering::Greater => {
|
||||||
next_val = Some(val.clone());
|
next_val = Some(val.clone());
|
||||||
next_pos = pos;
|
next_pos = pos;
|
||||||
} else if next == val {
|
}
|
||||||
|
Ordering::Equal => {
|
||||||
state.next = state.stream.as_mut().poll_next(cx);
|
state.next = state.stream.as_mut().poll_next(cx);
|
||||||
}
|
}
|
||||||
}
|
_ => (),
|
||||||
|
},
|
||||||
(Some(_), Poll::Ready(None)) => (),
|
(Some(_), Poll::Ready(None)) => (),
|
||||||
(None, Poll::Ready(None)) => (),
|
(None, Poll::Ready(None)) => (),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -218,13 +221,15 @@ impl Stream for ReadMergeStream<'_> {
|
||||||
min_time = t;
|
min_time = t;
|
||||||
}
|
}
|
||||||
(Some(min_key), Poll::Ready(Some(batch))) => {
|
(Some(min_key), Poll::Ready(Some(batch))) => {
|
||||||
if min_key > &batch.key {
|
match min_key.cmp(&batch.key) {
|
||||||
|
Ordering::Greater => {
|
||||||
next_min_key = Some(batch.key.clone());
|
next_min_key = Some(batch.key.clone());
|
||||||
min_pos = pos;
|
min_pos = pos;
|
||||||
positions = Vec::with_capacity(self.states.len());
|
positions = Vec::with_capacity(self.states.len());
|
||||||
let (_, t) = batch.start_stop_times();
|
let (_, t) = batch.start_stop_times();
|
||||||
min_time = t;
|
min_time = t;
|
||||||
} else if min_key == &batch.key {
|
}
|
||||||
|
Ordering::Equal => {
|
||||||
// if this batch has an end time less than the existing min time, make this
|
// if this batch has an end time less than the existing min time, make this
|
||||||
// the batch that we want to pull out first
|
// the batch that we want to pull out first
|
||||||
let (_, t) = batch.start_stop_times();
|
let (_, t) = batch.start_stop_times();
|
||||||
|
@ -236,6 +241,8 @@ impl Stream for ReadMergeStream<'_> {
|
||||||
positions.push(pos);
|
positions.push(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
(Some(_), Poll::Ready(None)) => (),
|
(Some(_), Poll::Ready(None)) => (),
|
||||||
(None, Poll::Ready(None)) => (),
|
(None, Poll::Ready(None)) => (),
|
||||||
|
|
Loading…
Reference in New Issue