clippy
This commit is contained in:
parent
7acf12a325
commit
8e3944d5df
@ -37,7 +37,7 @@ impl Blur {
|
||||
}
|
||||
|
||||
// Approximate 1D Gaussian filter of standard deviation sigma with N box filter passes. Each element in the output array contains the radius of the box filter for the corresponding pass.
|
||||
fn boxes_for_gaussian<const N: usize>(sigma: f32) -> ([usize; N]) {
|
||||
fn boxes_for_gaussian<const N: usize>(sigma: f32) -> [usize; N] {
|
||||
let w_ideal = (12.0 * sigma * sigma / N as f32 + 1.0).sqrt();
|
||||
let mut w = w_ideal as usize;
|
||||
w -= 1 - (w & 1);
|
||||
|
||||
@ -32,9 +32,9 @@ impl ThinGridData {
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn new_from_grid_vec(in_grids: Vec<Grid>) -> Vec<Self> {
|
||||
return in_grids.iter().map(|grid|{
|
||||
in_grids.iter().map(|grid|{
|
||||
Self::new_from_grid(grid)
|
||||
}).collect();
|
||||
}).collect()
|
||||
}
|
||||
|
||||
// from grid.rs (needed in image gen)
|
||||
@ -60,12 +60,12 @@ impl ThinGridData {
|
||||
|
||||
pub fn size_of(&self) -> usize {
|
||||
let mut output: usize = 0;
|
||||
output = output + std::mem::size_of_val(&self.width);
|
||||
output = output + std::mem::size_of_val(&self.height);
|
||||
output += std::mem::size_of_val(&self.width);
|
||||
output += std::mem::size_of_val(&self.height);
|
||||
for i in self.data.iter() {
|
||||
output = output + std::mem::size_of_val(&i);
|
||||
output += std::mem::size_of_val(&i);
|
||||
}
|
||||
return output;
|
||||
output
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,12 +97,12 @@ impl ImgData {
|
||||
|
||||
pub fn size_of(&self) -> usize {
|
||||
let mut output: usize = 0;
|
||||
output = output + std::mem::size_of_val(&self.iteration);
|
||||
output = output + std::mem::size_of_val(&self.palette);
|
||||
output += std::mem::size_of_val(&self.iteration);
|
||||
output += std::mem::size_of_val(&self.palette);
|
||||
for grid in self.grids.iter() {
|
||||
output = output + grid.size_of();
|
||||
output += grid.size_of();
|
||||
}
|
||||
return output;
|
||||
output
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
10
src/model.rs
10
src/model.rs
@ -132,7 +132,7 @@ impl Model {
|
||||
self.save_image_data();
|
||||
|
||||
let agents_tick_elapsed: f64 = agents_tick_time.elapsed().as_millis() as f64;
|
||||
let ms_per_agent: f64 = (agents_tick_elapsed as f64) / (agents_num as f64);
|
||||
let ms_per_agent: f64 = agents_tick_elapsed / (agents_num as f64);
|
||||
time_per_agent_list.push(ms_per_agent);
|
||||
time_per_step_list.push(agents_tick_elapsed);
|
||||
|
||||
@ -149,9 +149,9 @@ impl Model {
|
||||
pb.finish();
|
||||
|
||||
let avg_per_step: f64 =
|
||||
time_per_step_list.iter().sum::<f64>() as f64 / time_per_step_list.len() as f64;
|
||||
time_per_step_list.iter().sum::<f64>() / time_per_step_list.len() as f64;
|
||||
let avg_per_agent: f64 =
|
||||
time_per_agent_list.iter().sum::<f64>() as f64 / time_per_agent_list.len() as f64;
|
||||
time_per_agent_list.iter().sum::<f64>() / time_per_agent_list.len() as f64;
|
||||
println!(
|
||||
"Average time per step: {}ms\nAverage time per agent: {}ms",
|
||||
avg_per_step, avg_per_agent
|
||||
@ -159,7 +159,7 @@ impl Model {
|
||||
}
|
||||
|
||||
fn size_of_imgdata_vec(&self) -> usize {
|
||||
return (self.img_data_vec[0].size_of() as usize) * (self.img_data_vec.len() as usize);
|
||||
self.img_data_vec[0].size_of() * self.img_data_vec.len()
|
||||
}
|
||||
|
||||
fn save_image_data(&mut self) {
|
||||
@ -200,7 +200,7 @@ impl Model {
|
||||
pb.finish();
|
||||
*/
|
||||
|
||||
(&self.img_data_vec)
|
||||
self.img_data_vec
|
||||
.par_iter()
|
||||
.progress_with(pb)
|
||||
.for_each(|img| {
|
||||
|
||||
@ -15,7 +15,7 @@ pub fn random_palette() -> Palette {
|
||||
const fn hex_to_color(c: usize) -> image::Rgb<u8> {
|
||||
let r = (c >> 16) & 0xff;
|
||||
let g = (c >> 8) & 0xff;
|
||||
let b = (c >> 0) & 0xff;
|
||||
let b = c & 0xff;
|
||||
image::Rgb::<u8>([r as u8, g as u8, b as u8])
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user