perf(http): prefer ErrorKind::WouldBlock

Improved codegen, without allocations or function calls
This commit is contained in:
arthurprs
2017-09-03 18:58:19 +02:00
parent 50fd4ab96d
commit 1e7e1c921c
3 changed files with 4 additions and 4 deletions

View File

@@ -202,7 +202,7 @@ impl Chunked {
match *self {
Chunked::Init |
Chunked::End => Ok(msg.len()),
_ => Err(io::Error::new(io::ErrorKind::WouldBlock, "chunked incomplete"))
_ => Err(io::ErrorKind::WouldBlock.into())
}
}
}

View File

@@ -132,7 +132,7 @@ impl<T: Write> Write for Buffered<T> {
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
let n = self.write_buf.buffer(data);
if n == 0 {
Err(io::Error::from(io::ErrorKind::WouldBlock))
Err(io::ErrorKind::WouldBlock.into())
} else {
Ok(n)
}