Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codec: Some small improvements #4664

Merged
merged 10 commits into from May 10, 2019

Some generated files are not rendered by default. Learn more.

@@ -7,7 +7,8 @@ publish = false
[dependencies]
libc = "0.2"
byteorder = "1.2"
quick-error = "1.2"
failure = "0.1"
static_assertions = { version = "0.3", features = ["nightly"] }
panic_hook = { path = "../panic_hook" }
tikv_alloc = { path = "../tikv_alloc", default-features = false }

@@ -22,10 +22,7 @@ impl<T: AsRef<[u8]>> BufferReader for std::io::Cursor<T> {
fn bytes(&self) -> &[u8] {
let pos = self.position() as usize;
let slice = self.get_ref().as_ref();
if pos >= slice.len() {
return &[];
}
&slice[pos..]
slice.get(pos..).unwrap_or(&[])
}

fn advance(&mut self, count: usize) {
@@ -103,10 +100,7 @@ impl<T: AsMut<[u8]>> BufferWriter for std::io::Cursor<T> {
// `size` is ignored since this buffer is not capable to grow.
let pos = self.position() as usize;
let slice = self.get_mut().as_mut();
if pos >= slice.len() {
return &mut [];
}
&mut slice[pos..]
slice.get_mut(pos..).unwrap_or(&mut [])
}

unsafe fn advance_mut(&mut self, count: usize) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.