From 00d9019f29450a4fb423204ef87f718e4b4b79fc Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sun, 29 Apr 2018 19:27:40 +0300 Subject: [PATCH] Do not pass some things by value when not needed. --- hammond-gtk/src/utils.rs | 6 +++--- hammond-gtk/src/widgets/home_view.rs | 2 +- hammond-gtk/src/widgets/show.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hammond-gtk/src/utils.rs b/hammond-gtk/src/utils.rs index a2a57a3..c312a37 100644 --- a/hammond-gtk/src/utils.rs +++ b/hammond-gtk/src/utils.rs @@ -104,7 +104,7 @@ where // Kudos to Julian Sparber // https://blogs.gnome.org/jsparber/2018/04/29/animate-a-scrolledwindow/ -pub fn smooth_scroll_to(view: gtk::ScrolledWindow, target: gtk::Adjustment) { +pub fn smooth_scroll_to(view: >k::ScrolledWindow, target: >k::Adjustment) { if let Some(adj) = view.get_vadjustment() { if let Some(clock) = view.get_frame_clock() { let duration = 200; @@ -119,10 +119,10 @@ pub fn smooth_scroll_to(view: gtk::ScrolledWindow, target: gtk::Adjustment) { let mut t = (now - start_time) as f64 / (end_time - start_time) as f64; t = ease_out_cubic(t); adj.set_value(start + t * (end - start)); - return glib::Continue(true); + glib::Continue(true) } else { adj.set_value(end); - return glib::Continue(false); + glib::Continue(false) } }); } diff --git a/hammond-gtk/src/widgets/home_view.rs b/hammond-gtk/src/widgets/home_view.rs index 6334b06..bfcc66c 100644 --- a/hammond-gtk/src/widgets/home_view.rs +++ b/hammond-gtk/src/widgets/home_view.rs @@ -132,7 +132,7 @@ impl HomeView { // Copy the vertical scrollbar adjustment from the old view into the new one. sendcell .try_get() - .map(|x| utils::smooth_scroll_to(self.scrolled_window.clone(), x.clone())); + .map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x)); } Ok(()) diff --git a/hammond-gtk/src/widgets/show.rs b/hammond-gtk/src/widgets/show.rs index 3095518..ff37330 100644 --- a/hammond-gtk/src/widgets/show.rs +++ b/hammond-gtk/src/widgets/show.rs @@ -165,7 +165,7 @@ impl ShowWidget { // Copy the vertical scrollbar adjustment from the old view into the new one. sendcell .try_get() - .map(|x| utils::smooth_scroll_to(self.scrolled_window.clone(), x.clone())); + .map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x)); } Ok(())