From 4eb5779542e3d53d2a41f30f259640bb2f8069fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 18 Dec 2020 11:00:13 +0100 Subject: [PATCH] Remove redundant `f32` conversions in `image::Viewer` --- native/src/widget/image/viewer.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/native/src/widget/image/viewer.rs b/native/src/widget/image/viewer.rs index 0f081a1a..605298f1 100644 --- a/native/src/widget/image/viewer.rs +++ b/native/src/widget/image/viewer.rs @@ -371,12 +371,11 @@ impl State { /// [`Viewer`]: struct.Viewer.html /// [`State`]: struct.State.html fn pan(&mut self, x: f32, y: f32, bounds: Rectangle, image_size: Size) { - let hidden_width = ((image_size.width - bounds.width) as f32 / 2.0) - .max(0.0) - .round(); - let hidden_height = ((image_size.height - bounds.height) as f32 / 2.0) - .max(0.0) - .round(); + let hidden_width = + (image_size.width - bounds.width / 2.0).max(0.0).round(); + + let hidden_height = + (image_size.height - bounds.height / 2.0).max(0.0).round(); let delta_x = x - self.starting_cursor_pos.unwrap().x; let delta_y = y - self.starting_cursor_pos.unwrap().y; @@ -400,12 +399,11 @@ impl State { /// [`Viewer`]: struct.Viewer.html /// [`State`]: struct.State.html fn offset(&self, bounds: Rectangle, image_size: Size) -> Vector { - let hidden_width = ((image_size.width - bounds.width) as f32 / 2.0) - .max(0.0) - .round(); - let hidden_height = ((image_size.height - bounds.height) as f32 / 2.0) - .max(0.0) - .round(); + let hidden_width = + (image_size.width - bounds.width / 2.0).max(0.0).round(); + + let hidden_height = + (image_size.height - bounds.height / 2.0).max(0.0).round(); Vector::new( self.current_offset