ByteBaker commented on issue #37:
URL: https://github.com/apache/arrow-rs/issues/37#issuecomment-2362081355
One good thing that's happening is that I'm also finding some of the
trivial, but overlooked code-pieces. For example:
```rust
fn write(&mut self, buf: &[u8]) -> Result<usize> {
let string = match String::from_utf8(buf) { // Should've been
`str::from_utf8`, avoids allocation
Ok(x) => x,
Err(e) => {
return Err(Error::new(ErrorKind::InvalidData, e));
}
};
self.data.push_str(&string); // With `str::from_utf8`, a reference
won't be necessary
Ok(string.len())
}
```
I'm also changing these as they're not too much work and are trivial
changes. I hope that's okay?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]