diff options
author | Joe Wilm <joe@jwilm.com> | 2016-06-30 21:26:26 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-06-30 21:26:26 -0700 |
commit | d514b382237d4df2e33503602ec2af4c0cbb2189 (patch) | |
tree | ec58dfd7ba9b812365806d7bc516eb3795bc173a /src/main.rs | |
parent | d304ea9b774662ca05384b6633507362e389f7a9 (diff) | |
download | r-alacritty-d514b382237d4df2e33503602ec2af4c0cbb2189.tar.gz r-alacritty-d514b382237d4df2e33503602ec2af4c0cbb2189.tar.bz2 r-alacritty-d514b382237d4df2e33503602ec2af4c0cbb2189.zip |
Vendor upcoming Utf8Chars iterator from libstd
The upcoming Utf8Chars iterator was vendored from a libstd PR. The
iterator works on BufRead types which is critical for improving
performance. A small modification was made where the number of unused
bytes is included with Utf8CharsError::IncompleteUtf8.
The pty reader thread was updated to use this new type. Next steps will
be moving the parsing there and either sending parse results in batches
or updating the terminal directly from that thread.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index b699fe44..cbfa7425 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,6 @@ #![feature(question_mark)] #![feature(range_contains)] #![feature(inclusive_range_syntax)] -#![feature(io)] #![feature(drop_types_in_const)] #![feature(unicode)] #![feature(custom_derive, plugin)] @@ -47,8 +46,9 @@ mod tty; pub mod ansi; mod term; mod util; +mod io; -use std::io::{Read, Write, BufWriter}; +use std::io::{Write, BufWriter, BufReader}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{mpsc, Arc}; @@ -62,6 +62,8 @@ use term::Term; use tty::process_should_exit; use util::thread; +use io::Utf8Chars; + /// Things that the render/update thread needs to respond to #[derive(Debug)] enum Event { @@ -189,7 +191,8 @@ fn main() { resize_sender = Some(tx.clone()); } let reader_thread = thread::spawn_named("TTY Reader", move || { - for c in reader.chars() { + let chars = Utf8Chars::new(BufReader::new(reader)); + for c in chars { let c = c.unwrap(); reader_tx.send(Event::PtyChar(c)).unwrap(); } |