Avoid hanging waiting for operations when buffer has none

This commit is contained in:
Antonio Scandurra 2022-12-23 12:26:48 +01:00
parent 75803d8dbb
commit 344d05045d

View File

@ -6255,16 +6255,19 @@ fn split_operations(
#[cfg(not(any(test, feature = "test-support")))]
const CHUNK_SIZE: usize = 100;
let mut done = false;
std::iter::from_fn(move || {
if operations.is_empty() {
if done {
return None;
}
Some(
operations
let operations = operations
.drain(..cmp::min(CHUNK_SIZE, operations.len()))
.collect(),
)
.collect::<Vec<_>>();
if operations.is_empty() {
done = true;
}
Some(operations)
})
}