diff options
-rw-r--r-- | components/compositing/compositor.rs | 10 | ||||
-rw-r--r-- | components/devtools/lib.rs | 13 | ||||
-rw-r--r-- | components/gfx/text/shaping/harfbuzz.rs | 5 | ||||
-rw-r--r-- | components/profile/time.rs | 11 | ||||
-rw-r--r-- | components/script/dom/treewalker.rs | 9 | ||||
-rw-r--r-- | components/style/str.rs | 5 | ||||
-rw-r--r-- | ports/cef/window.rs | 44 |
7 files changed, 39 insertions, 58 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 4f667bfbef3..2cd61515039 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -449,13 +449,11 @@ impl<Window: WindowMethods> IOCompositor<Window> { while self.port.try_recv_compositor_msg().is_some() {} // Tell the profiler, memory profiler, and scrolling timer to shut down. - match ipc::channel() { - Ok((sender, receiver)) => { - self.time_profiler_chan.send(time::ProfilerMsg::Exit(sender)); - let _ = receiver.recv(); - }, - Err(_) => {}, + if let Ok((sender, receiver)) = ipc::channel() { + self.time_profiler_chan.send(time::ProfilerMsg::Exit(sender)); + let _ = receiver.recv(); } + self.delayed_composition_timer.shutdown(); self.shutdown_state = ShutdownState::FinishedShuttingDown; diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index c98bb270333..b492f774e07 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -179,14 +179,11 @@ fn run_server(sender: Sender<DevtoolsControlMsg>, 'outer: loop { match stream.read_json_packet() { Ok(Some(json_packet)) => { - match actors.lock().unwrap().handle_message(json_packet.as_object().unwrap(), - &mut stream) { - Ok(()) => {}, - Err(()) => { - debug!("error: devtools actor stopped responding"); - let _ = stream.shutdown(Shutdown::Both); - break 'outer - } + if let Err(()) = actors.lock().unwrap().handle_message(json_packet.as_object().unwrap(), + &mut stream) { + debug!("error: devtools actor stopped responding"); + let _ = stream.shutdown(Shutdown::Both); + break 'outer } } Ok(None) => { diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index 9f9f1e16751..6285ab42133 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -393,9 +393,8 @@ impl Shaper { fn advance_for_shaped_glyph(&self, mut advance: Au, character: char, options: &ShapingOptions) -> Au { - match options.letter_spacing { - None => {} - Some(letter_spacing) => advance = advance + letter_spacing, + if let Some(letter_spacing) = options.letter_spacing { + advance = advance + letter_spacing; }; // CSS 2.1 § 16.4 states that "word spacing affects each space (U+0020) and non-breaking diff --git a/components/profile/time.rs b/components/profile/time.rs index c246aabee1b..e02de039360 100644 --- a/components/profile/time.rs +++ b/components/profile/time.rs @@ -262,12 +262,11 @@ impl Profiler { // send using the inner channel // (using ProfilerChan.send() forces an unwrap and sometimes panics for this background profiler) let ProfilerChan(ref c) = profiler_chan; - match c.send(ProfilerMsg::Time((ProfilerCategory::ApplicationHeartbeat, None), - (start_time, end_time), - (start_energy, end_energy))) { - Ok(_) => {}, - Err(_) => return, - }; + if let Err(_) = c.send(ProfilerMsg::Time((ProfilerCategory::ApplicationHeartbeat, None), + (start_time, end_time), + (start_energy, end_energy))) { + return; + } start_time = end_time; start_energy = end_energy; } diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index 2a3367b3393..6dba79e893b 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -286,13 +286,10 @@ impl TreeWalker { NodeFilterConstants::FILTER_SKIP => { // "1. Let child be node's first child if type is first, // and node's last child if type is last." - match next_child(&node) { + if let Some(child) = next_child(&node) { // "2. If child is not null, set node to child and goto Main." - Some(child) => { - node = child; - continue 'main - }, - None => {} + node = child; + continue 'main } }, _ => {} diff --git a/components/style/str.rs b/components/style/str.rs index e84394ece39..ee805b1d801 100644 --- a/components/style/str.rs +++ b/components/style/str.rs @@ -150,9 +150,8 @@ pub fn str_join<I, T>(strs: I, join: &str) -> String /// Like AsciiExt::to_ascii_lowercase, but avoids allocating when the input is already lower-case. pub fn cow_into_ascii_lowercase<'a, S: Into<Cow<'a, str>>>(s: S) -> Cow<'a, str> { let mut cow = s.into(); - match cow.bytes().position(|byte| byte >= b'A' && byte <= b'Z') { - Some(first_uppercase) => cow.to_mut()[first_uppercase..].make_ascii_lowercase(), - None => {} + if let Some(first_uppercase) = cow.bytes().position(|byte| byte >= b'A' && byte <= b'Z') { + cow.to_mut()[first_uppercase..].make_ascii_lowercase(); } cow } diff --git a/ports/cef/window.rs b/ports/cef/window.rs index ee76ddd3035..6886ff018fa 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -242,13 +242,10 @@ impl WindowMethods for Window { fn present(&self) { let browser = self.cef_browser.borrow(); - match *browser { - None => {} - Some(ref browser) => { - if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && - check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_present) { - browser.get_host().get_client().get_render_handler().on_present(browser.clone()); - } + if let Some(ref browser) = *browser { + if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && + check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_present) { + browser.get_host().get_client().get_render_handler().on_present(browser.clone()); } } } @@ -432,12 +429,10 @@ impl WindowMethods for Window { check_ptr_exist!(browser.get_host().get_client().get_display_handler(), on_title_change) { browser.get_host().get_client().get_display_handler().on_title_change((*browser).clone(), str.as_slice()); } - match &mut *title_visitor { - &mut None => {}, - &mut Some(ref mut visitor) => { - visitor.visit(&str); - } - }; + + if let Some(ref mut visitor) = *title_visitor { + visitor.visit(&str); + } } fn set_page_url(&self, url: ServoUrl) { @@ -468,19 +463,16 @@ impl WindowMethods for Window { fn set_cursor(&self, cursor: Cursor) { use types::{CefCursorInfo,cef_point_t,cef_size_t}; let browser = self.cef_browser.borrow(); - match *browser { - None => {} - Some(ref browser) => { - let cursor_handle = self.cursor_handle_for_cursor(cursor); - let info = CefCursorInfo { hotspot: cef_point_t {x: 0, y: 0}, image_scale_factor: 0.0, buffer: 0 as *mut isize, size: cef_size_t { width: 0, height: 0 } }; - if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && - check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_cursor_change) { - browser.get_host() - .get_client() - .get_render_handler() - .on_cursor_change(browser.clone(), cursor_handle, - self.cursor_type_for_cursor(cursor), &info) - } + if let Some(ref browser) = *browser { + let cursor_handle = self.cursor_handle_for_cursor(cursor); + let info = CefCursorInfo { hotspot: cef_point_t {x: 0, y: 0}, image_scale_factor: 0.0, buffer: 0 as *mut isize, size: cef_size_t { width: 0, height: 0 } }; + if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && + check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_cursor_change) { + browser.get_host() + .get_client() + .get_render_handler() + .on_cursor_change(browser.clone(), cursor_handle, + self.cursor_type_for_cursor(cursor), &info); } } } |