servo: Merge #8393 - Use while let{} instead of loop{match{}} (from rnestler:fix_8384); r=frewsxcv
authorRaphael Nestler <raphael.nestler@gmail.com>
Sun, 08 Nov 2015 01:16:51 +0500
changeset 337537 67290bc893408830479facd936b6a71d757b1652
parent 337536 ab102aeed2a91492c0fe0ca003ad1e6594cb8b05
child 337538 d2b2879269e6fa1fd3bb39a9dc2df298491ea02d
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrewsxcv
servo: Merge #8393 - Use while let{} instead of loop{match{}} (from rnestler:fix_8384); r=frewsxcv This fixes #8384 Source-Repo: https://github.com/servo/servo Source-Revision: 1979d0a2e63fb7bb52d560b697b045a8743c0d96
servo/components/compositing/compositor.rs
servo/components/compositing/scrolling.rs
--- a/servo/components/compositing/compositor.rs
+++ b/servo/components/compositing/compositor.rs
@@ -2120,24 +2120,19 @@ fn find_layer_with_pipeline_and_layer_id
     }
 
     return None;
 }
 
 impl<Window> CompositorEventListener for IOCompositor<Window> where Window: WindowMethods {
     fn handle_events(&mut self, messages: Vec<WindowEvent>) -> bool {
         // Check for new messages coming from the other tasks in the system.
-        loop {
-            match self.port.try_recv_compositor_msg() {
-                None => break,
-                Some(msg) => {
-                    if !self.handle_browser_message(msg) {
-                        break
-                    }
-                }
+        while let Some(msg) = self.port.try_recv_compositor_msg() {
+            if !self.handle_browser_message(msg) {
+                break
             }
         }
 
         if self.shutdown_state == ShutdownState::FinishedShuttingDown {
             return false;
         }
 
         // Handle any messages coming from the windowing system.
--- a/servo/components/compositing/scrolling.rs
+++ b/servo/components/compositing/scrolling.rs
@@ -49,22 +49,17 @@ impl ScrollingTimerProxy {
 
     pub fn shutdown(&mut self) {
         self.sender.send(ToScrollingTimerMsg::ExitMsg).unwrap()
     }
 }
 
 impl ScrollingTimer {
     pub fn run(&mut self) {
-        loop {
-            match self.receiver.recv() {
-                Ok(ToScrollingTimerMsg::ScrollEventProcessedMsg(timestamp)) => {
-                    let target = timestamp as i64 + TIMEOUT;
-                    let delta_ns = target - (time::precise_time_ns() as i64);
-                    sleep_ms((delta_ns / 1000000) as u32);
-                    self.compositor_proxy.send(Msg::ScrollTimeout(timestamp));
-                }
-                Ok(ToScrollingTimerMsg::ExitMsg) | Err(_) => break,
-            }
+        while let Ok(ToScrollingTimerMsg::ScrollEventProcessedMsg(timestamp)) = self.receiver.recv() {
+            let target = timestamp as i64 + TIMEOUT;
+            let delta_ns = target - (time::precise_time_ns() as i64);
+            sleep_ms((delta_ns / 1000000) as u32);
+            self.compositor_proxy.send(Msg::ScrollTimeout(timestamp));
         }
     }
 }