From 112abf385fef32f30618b4ebb1d1c651661a6fae Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Wed, 24 May 2017 09:50:49 -0700 Subject: Minor cleanup, style fix, dead code removal --- src/event_loop.rs | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/event_loop.rs b/src/event_loop.rs index ee5624c7..c744dda0 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -58,7 +58,6 @@ enum DrainResult { } impl DrainResult { - pub fn is_shutdown(&self) -> bool { match *self { DrainResult::Shutdown => true, @@ -66,22 +65,12 @@ impl DrainResult { } } - #[allow(dead_code)] pub fn is_empty(&self) -> bool { match *self { DrainResult::Empty => true, _ => false } } - - #[allow(dead_code)] - pub fn is_item(&self) -> bool { - match *self { - DrainResult::ReceivedItem => true, - _ => false - } - } - } /// All of the mutable state needed to run the event loop @@ -226,7 +215,11 @@ impl EventLoop } } - return if received_item { DrainResult::ReceivedItem } else { DrainResult::Empty }; + if received_item { + DrainResult::ReceivedItem + } else { + DrainResult::Empty + } } // Returns a `bool` indicating whether or not the event loop should continue running @@ -250,6 +243,7 @@ impl EventLoop PollOpt::edge() | PollOpt::oneshot() ).expect("reregister fd after channel recv"); } + true } @@ -291,14 +285,11 @@ impl EventLoop // Doing this check in !terminal.dirty will prevent the // condition from being checked overzealously. // - // We want to break if `drain_recv_channel` returns either `Ok(true)` - // (new items came in for writing) or `Err` (we need to shut down) + // Break if `drain_recv_channel` signals there is work to do or + // shutting down. if state.writing.is_some() || !state.write_list.is_empty() - || match self.drain_recv_channel(state) { - DrainResult::Shutdown | DrainResult::ReceivedItem => true, - _ => false - } + || !self.drain_recv_channel(state).is_empty() { break; } -- cgit v1.2.3-54-g00ecf