From 776021082442107567ad7be6df47d8ca51a030c5 Mon Sep 17 00:00:00 2001 From: Imbris Date: Sun, 28 Nov 2021 12:24:57 -0500 Subject: [PATCH] Remove redundant closures --- common/src/combat.rs | 6 ++--- voxygen/src/mesh/terrain.rs | 4 +--- world/src/sim/erosion.rs | 47 ++++++++----------------------------- 3 files changed, 14 insertions(+), 43 deletions(-) diff --git a/common/src/combat.rs b/common/src/combat.rs index 1099e94a09..9f6ad903a5 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -171,7 +171,7 @@ impl Attack { 1.0 - (1.0 - damage_reduction) * (1.0 - block_reduction) } - #[allow(clippy::too_many_arguments, clippy::redundant_closure)] + #[allow(clippy::too_many_arguments)] pub fn apply_attack( &self, attacker: Option, @@ -220,8 +220,8 @@ impl Attack { attack_source, dir, damage.damage.kind, - |e| emit(e), - |o| emit_outcome(o), + &mut emit, + &mut emit_outcome, ); let change = damage.damage.calculate_health_change( damage_reduction, diff --git a/voxygen/src/mesh/terrain.rs b/voxygen/src/mesh/terrain.rs index ce071eca39..605d10ba14 100644 --- a/voxygen/src/mesh/terrain.rs +++ b/voxygen/src/mesh/terrain.rs @@ -381,10 +381,8 @@ pub fn generate_mesh<'a, V: RectRasterableVol + ReadVol + Debug + ' let get_color = |_: &mut (), pos: Vec3| flat_get(pos).get_color().unwrap_or_else(Rgb::zero); let get_opacity = |_: &mut (), pos: Vec3| !flat_get(pos).is_opaque(); - #[allow(clippy::redundant_closure)] - let flat_get = |pos| flat_get(pos); let should_draw = |_: &mut (), pos: Vec3, delta: Vec3, _uv| { - should_draw_greedy(pos, delta, flat_get) + should_draw_greedy(pos, delta, &flat_get) }; // NOTE: Conversion to f32 is fine since this i32 is actually in bounds for u16. let mesh_delta = Vec3::new(0.0, 0.0, (z_start + range.min.z) as f32); diff --git a/world/src/sim/erosion.rs b/world/src/sim/erosion.rs index 0187b2ff6b..9f1bf3b6c2 100644 --- a/world/src/sim/erosion.rs +++ b/world/src/sim/erosion.rs @@ -1750,10 +1750,7 @@ pub(crate) fn fill_sinks( let range = 0..map_size_lg.chunks_len(); let oldh = range .into_par_iter() - .map( - #[allow(clippy::redundant_closure)] - |posi| h(posi), - ) + .map(&h) .collect::>() .into_boxed_slice(); let mut newh = oldh @@ -2577,10 +2574,7 @@ pub fn do_erosion( // Stream power law slope exponent--link between channel slope and erosion rate. let n = (0..map_size_lg.chunks_len()) .into_par_iter() - .map( - #[allow(clippy::redundant_closure)] - |posi| n(posi), - ) + .map(&n) .collect::>() .into_boxed_slice(); // Stream power law concavity index (θ = m/n), turned into an exponent on @@ -2593,44 +2587,29 @@ pub fn do_erosion( // Stream power law erodability constant for fluvial erosion (bedrock) let kf = (0..map_size_lg.chunks_len()) .into_par_iter() - .map( - #[allow(clippy::redundant_closure)] - |posi| kf(posi), - ) + .map(&kf) .collect::>() .into_boxed_slice(); // Stream power law erodability constant for hillslope diffusion (bedrock) let kd = (0..map_size_lg.chunks_len()) .into_par_iter() - .map( - #[allow(clippy::redundant_closure)] - |posi| kd(posi), - ) + .map(&kd) .collect::>() .into_boxed_slice(); // Deposition coefficient let g = (0..map_size_lg.chunks_len()) .into_par_iter() - .map( - #[allow(clippy::redundant_closure)] - |posi| g(posi), - ) + .map(&g) .collect::>() .into_boxed_slice(); let epsilon_0 = (0..map_size_lg.chunks_len()) .into_par_iter() - .map( - #[allow(clippy::redundant_closure)] - |posi| epsilon_0(posi), - ) + .map(&epsilon_0) .collect::>() .into_boxed_slice(); let alpha = (0..map_size_lg.chunks_len()) .into_par_iter() - .map( - #[allow(clippy::redundant_closure)] - |posi| alpha(posi), - ) + .map(&alpha) .collect::>() .into_boxed_slice(); let mut wh = vec![0.0; map_size_lg.chunks_len()].into_boxed_slice(); @@ -2676,12 +2655,6 @@ pub fn do_erosion( let g = |posi: usize| g[posi]; let epsilon_0 = |posi: usize| epsilon_0[posi]; let alpha = |posi: usize| alpha[posi]; - #[allow(clippy::redundant_closure)] - let height_scale = |n| height_scale(n); - #[allow(clippy::redundant_closure)] - let k_da_scale = |q| k_da_scale(q); - #[allow(clippy::redundant_closure)] - let is_ocean = |posi| is_ocean(posi); (0..n_steps).for_each(|i| { debug!("Erosion iteration #{:?}", i); @@ -2703,9 +2676,9 @@ pub fn do_erosion( g, epsilon_0, alpha, - is_ocean, - height_scale, - k_da_scale, + &is_ocean, + &height_scale, + &k_da_scale, threadpool, ); });