From d514b382237d4df2e33503602ec2af4c0cbb2189 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Thu, 30 Jun 2016 21:26:26 -0700 Subject: 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. --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main.rs') 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(); } -- cgit