From 2cc5bbf21b654c26bfd8b1e80b1e5c7cbd81235f Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 8 Sep 2019 16:56:31 -0700 Subject: [PATCH] Inline buffer methods --- postgres-protocol/src/message/backend.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/postgres-protocol/src/message/backend.rs b/postgres-protocol/src/message/backend.rs index 909f8bfd..0cf1c4f0 100644 --- a/postgres-protocol/src/message/backend.rs +++ b/postgres-protocol/src/message/backend.rs @@ -285,14 +285,17 @@ struct Buffer { } impl Buffer { + #[inline] fn slice(&self) -> &[u8] { &self.bytes[self.idx..] } + #[inline] fn is_empty(&self) -> bool { self.slice().is_empty() } + #[inline] fn read_cstr(&mut self) -> io::Result { match memchr(0, self.slice()) { Some(pos) => { @@ -309,6 +312,7 @@ impl Buffer { } } + #[inline] fn read_all(&mut self) -> Bytes { let buf = self.bytes.slice_from(self.idx); self.idx = self.bytes.len(); @@ -317,6 +321,7 @@ impl Buffer { } impl Read for Buffer { + #[inline] fn read(&mut self, buf: &mut [u8]) -> io::Result { let len = { let slice = self.slice();