Merge branch 'imbris/redundant-closure' into 'master'

Remove redundant closures

See merge request veloren/veloren!3033
This commit is contained in:
Marcel 2021-11-28 18:13:01 +00:00
commit 8613cdfe36
3 changed files with 14 additions and 43 deletions

View File

@ -171,7 +171,7 @@ impl Attack {
1.0 - (1.0 - damage_reduction) * (1.0 - block_reduction) 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( pub fn apply_attack(
&self, &self,
attacker: Option<AttackerInfo>, attacker: Option<AttackerInfo>,
@ -220,8 +220,8 @@ impl Attack {
attack_source, attack_source,
dir, dir,
damage.damage.kind, damage.damage.kind,
|e| emit(e), &mut emit,
|o| emit_outcome(o), &mut emit_outcome,
); );
let change = damage.damage.calculate_health_change( let change = damage.damage.calculate_health_change(
damage_reduction, damage_reduction,

View File

@ -381,10 +381,8 @@ pub fn generate_mesh<'a, V: RectRasterableVol<Vox = Block> + ReadVol + Debug + '
let get_color = let get_color =
|_: &mut (), pos: Vec3<i32>| flat_get(pos).get_color().unwrap_or_else(Rgb::zero); |_: &mut (), pos: Vec3<i32>| flat_get(pos).get_color().unwrap_or_else(Rgb::zero);
let get_opacity = |_: &mut (), pos: Vec3<i32>| !flat_get(pos).is_opaque(); let get_opacity = |_: &mut (), pos: Vec3<i32>| !flat_get(pos).is_opaque();
#[allow(clippy::redundant_closure)]
let flat_get = |pos| flat_get(pos);
let should_draw = |_: &mut (), pos: Vec3<i32>, delta: Vec3<i32>, _uv| { let should_draw = |_: &mut (), pos: Vec3<i32>, delta: Vec3<i32>, _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. // 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); let mesh_delta = Vec3::new(0.0, 0.0, (z_start + range.min.z) as f32);

View File

@ -1750,10 +1750,7 @@ pub(crate) fn fill_sinks<F: Float + Send + Sync>(
let range = 0..map_size_lg.chunks_len(); let range = 0..map_size_lg.chunks_len();
let oldh = range let oldh = range
.into_par_iter() .into_par_iter()
.map( .map(&h)
#[allow(clippy::redundant_closure)]
|posi| h(posi),
)
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_boxed_slice(); .into_boxed_slice();
let mut newh = oldh let mut newh = oldh
@ -2577,10 +2574,7 @@ pub fn do_erosion(
// Stream power law slope exponent--link between channel slope and erosion rate. // Stream power law slope exponent--link between channel slope and erosion rate.
let n = (0..map_size_lg.chunks_len()) let n = (0..map_size_lg.chunks_len())
.into_par_iter() .into_par_iter()
.map( .map(&n)
#[allow(clippy::redundant_closure)]
|posi| n(posi),
)
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_boxed_slice(); .into_boxed_slice();
// Stream power law concavity index (θ = m/n), turned into an exponent on // 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) // Stream power law erodability constant for fluvial erosion (bedrock)
let kf = (0..map_size_lg.chunks_len()) let kf = (0..map_size_lg.chunks_len())
.into_par_iter() .into_par_iter()
.map( .map(&kf)
#[allow(clippy::redundant_closure)]
|posi| kf(posi),
)
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_boxed_slice(); .into_boxed_slice();
// Stream power law erodability constant for hillslope diffusion (bedrock) // Stream power law erodability constant for hillslope diffusion (bedrock)
let kd = (0..map_size_lg.chunks_len()) let kd = (0..map_size_lg.chunks_len())
.into_par_iter() .into_par_iter()
.map( .map(&kd)
#[allow(clippy::redundant_closure)]
|posi| kd(posi),
)
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_boxed_slice(); .into_boxed_slice();
// Deposition coefficient // Deposition coefficient
let g = (0..map_size_lg.chunks_len()) let g = (0..map_size_lg.chunks_len())
.into_par_iter() .into_par_iter()
.map( .map(&g)
#[allow(clippy::redundant_closure)]
|posi| g(posi),
)
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_boxed_slice(); .into_boxed_slice();
let epsilon_0 = (0..map_size_lg.chunks_len()) let epsilon_0 = (0..map_size_lg.chunks_len())
.into_par_iter() .into_par_iter()
.map( .map(&epsilon_0)
#[allow(clippy::redundant_closure)]
|posi| epsilon_0(posi),
)
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_boxed_slice(); .into_boxed_slice();
let alpha = (0..map_size_lg.chunks_len()) let alpha = (0..map_size_lg.chunks_len())
.into_par_iter() .into_par_iter()
.map( .map(&alpha)
#[allow(clippy::redundant_closure)]
|posi| alpha(posi),
)
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_boxed_slice(); .into_boxed_slice();
let mut wh = vec![0.0; map_size_lg.chunks_len()].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 g = |posi: usize| g[posi];
let epsilon_0 = |posi: usize| epsilon_0[posi]; let epsilon_0 = |posi: usize| epsilon_0[posi];
let alpha = |posi: usize| alpha[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| { (0..n_steps).for_each(|i| {
debug!("Erosion iteration #{:?}", i); debug!("Erosion iteration #{:?}", i);
@ -2703,9 +2676,9 @@ pub fn do_erosion(
g, g,
epsilon_0, epsilon_0,
alpha, alpha,
is_ocean, &is_ocean,
height_scale, &height_scale,
k_da_scale, &k_da_scale,
threadpool, threadpool,
); );
}); });