From 954a05919dded30846c92e19321d623045c396f7 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 5 Jun 2020 07:33:23 -0700 Subject: [PATCH] pty: remove dead code --- pty/src/win/mod.rs | 1 - pty/src/win/readbuf.rs | 44 ------------------------------------------ 2 files changed, 45 deletions(-) delete mode 100644 pty/src/win/readbuf.rs diff --git a/pty/src/win/mod.rs b/pty/src/win/mod.rs index 7837a6f16..0e9007143 100644 --- a/pty/src/win/mod.rs +++ b/pty/src/win/mod.rs @@ -13,7 +13,6 @@ use winapi::um::winbase::INFINITE; pub mod conpty; mod procthreadattr; mod psuedocon; -mod readbuf; use filedescriptor::OwnedHandle; diff --git a/pty/src/win/readbuf.rs b/pty/src/win/readbuf.rs deleted file mode 100644 index 24612dd17..000000000 --- a/pty/src/win/readbuf.rs +++ /dev/null @@ -1,44 +0,0 @@ -/// A simple read buffer -pub struct ReadBuffer { - data: Vec, - /// The position to read data from - pos: usize, -} - -impl ReadBuffer { - pub fn new() -> Self { - let data = Vec::with_capacity(8192); - Self { data, pos: 0 } - } - - pub fn append(&mut self, buf: &[u8]) { - if self.data.len() + buf.len() > self.data.capacity() { - if self.pos == self.data.len() { - self.pos = 0; - } else if self.pos > 0 { - let (front, back) = self.data.split_at_mut(self.pos); - let len = back.len(); - front[0..len].copy_from_slice(back); - - self.pos = len; - self.data.resize(len, 0); - } - } - self.data.extend_from_slice(buf); - } - - pub fn avail(&self) -> usize { - self.data.len() - self.pos - } - - pub fn consume(&mut self, buf: &mut [u8]) -> usize { - let len = buf.len().min(self.avail()); - if len == 0 { - 0 - } else { - buf[0..len].copy_from_slice(&self.data[self.pos..self.pos + len]); - self.pos += len; - len - } - } -}