Skip to content

Commit

Permalink
Block read read single input event
Browse files Browse the repository at this point in the history
  • Loading branch information
TimonPost authored Oct 8, 2019
2 parents 8ffdb0a + ba2a6a7 commit eea5cea
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,11 @@ impl Console {
Ok(utf8.as_bytes().len())
}

pub fn read_single_input_event(&self) -> Result<Option<InputRecord>> {
let buf_len = self.number_of_console_input_events()?;

// Fast-skipping all the code below if there is nothing to read at all
if buf_len == 0 {
return Ok(None);
}

pub fn read_single_input_event(&self) -> Result<InputRecord> {
let mut buf: Vec<INPUT_RECORD> = Vec::with_capacity(1);
let mut size = 0;

let a = self.read_input(&mut buf, 1, &mut size)?.1[0].to_owned();

// read single input event
Ok(Some(a))
return Ok(self.read_input(&mut buf, 1, &mut size)?.1[0].to_owned());
}

pub fn read_console_input(&self) -> Result<(u32, Vec<InputRecord>)> {
Expand Down

0 comments on commit eea5cea

Please sign in to comment.