Skip to content

Commit 386f59e

Browse files
authored
Early return in do_poll_read instead of keep polling (#404)
if there're some data already written to `output`, so that the next component in pipeline can process it instead of being blocked.
1 parent 6c0835e commit 386f59e

File tree

1 file changed

+6
-3
lines changed
  • crates/async-compression/src/generic/bufread

1 file changed

+6
-3
lines changed

crates/async-compression/src/generic/bufread/encoder.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ impl Encoder {
3535
State::Encoding(mut read) => match input.as_mut() {
3636
None => {
3737
if read == 0 {
38-
// Poll for more data
39-
// TODO (nobodyxu): Return Ok if `!output.written().is_empty()`
40-
break;
38+
if output.written().is_empty() {
39+
// Poll for more data
40+
break;
41+
} else {
42+
return ControlFlow::Break(Ok(()));
43+
}
4144
} else {
4245
State::Flushing
4346
}

0 commit comments

Comments
 (0)