Skip to content

Commit

Permalink
fix: read faststr should use bytes instead of bytesmut (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWhiteWu authored Dec 8, 2022
1 parent d2e3759 commit 136cfe8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pilota/src/thrift/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,9 @@ impl TInputProtocol for TBinaryProtocol<&mut BytesMut> {
#[inline]
fn read_faststr(&mut self) -> Result<FastStr, Error> {
let len = self.trans.read_i32()? as usize;
let bytes = self.trans.split_to(len);
let bytes = self.trans.split_to(len).freeze();
if len > INLINE_CAP {
unsafe { return Ok(FastStr::from_bytes_mut_unchecked(bytes)) };
unsafe { return Ok(FastStr::from_bytes_unchecked(bytes)) };
}
unsafe { Ok(FastStr::new_inline(str::from_utf8_unchecked(bytes.deref()))) }
}
Expand Down

0 comments on commit 136cfe8

Please sign in to comment.