style(simulation): fmt + clippy fixes for the measurement batch (gate bounce)
cargo fmt across the four new files; needless_range_loop x2 (enumerate / iter_mut) and identity_op in hydrology_equilibrium.rs. cargo test was green on the bounced push — lint-only fixes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
use std::io::Cursor;
|
||||
use std::time::Instant;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settled_reach_server::atlas::believability::seed_to_u64;
|
||||
use settled_reach_server::atlas::district_profile::{
|
||||
derive_at_metres, BodyParams, ClimateConstants,
|
||||
@@ -41,7 +42,6 @@ use settled_reach_server::atlas::heightmap::load_heightmap_png;
|
||||
use settled_reach_server::atlas::layer_proxy::REGION_TEMP_NONE_DC;
|
||||
use settled_reach_server::atlas::scale;
|
||||
use settled_reach_server::seed::SeedChain;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The six wire arrays `DistrictWindowLayer` ships today (layer_proxy.rs),
|
||||
/// derived at full canvas size rather than the 4,096-cell window cap.
|
||||
@@ -103,9 +103,8 @@ fn derive_canvas(
|
||||
.map(|col| {
|
||||
let wx = col as f64 * step_m;
|
||||
let wy = row as f64 * step_m;
|
||||
let prof = derive_at_metres(
|
||||
seed, "GJ338Bd", params, ta, wx, wy, &climate, 0.0, &[],
|
||||
);
|
||||
let prof =
|
||||
derive_at_metres(seed, "GJ338Bd", params, ta, wx, wy, &climate, 0.0, &[]);
|
||||
let temp_dc = match prof.temperature_c {
|
||||
Some(t) => ((t * 10.0).round() as i32)
|
||||
.clamp(i16::MIN as i32 + 1, i16::MAX as i32)
|
||||
@@ -265,7 +264,13 @@ fn encode_bitpacked(canvas: &WireCanvas) -> (Vec<u8>, std::time::Duration, std::
|
||||
let vegetation = unpack_bits(&decoded.vegetation_bits, 3, n);
|
||||
let glaciation = unpack_bits(&decoded.glaciation_bits, 3, n);
|
||||
let dec_time = t1.elapsed();
|
||||
std::hint::black_box((morphology.len(), elev_q.len(), moisture_q.len(), vegetation.len(), glaciation.len()));
|
||||
std::hint::black_box((
|
||||
morphology.len(),
|
||||
elev_q.len(),
|
||||
moisture_q.len(),
|
||||
vegetation.len(),
|
||||
glaciation.len(),
|
||||
));
|
||||
(bytes, enc_time, dec_time)
|
||||
}
|
||||
|
||||
@@ -404,7 +409,9 @@ fn png_encode_u8_plane(cols: u32, rows: u32, data: &[u8]) -> Vec<u8> {
|
||||
}
|
||||
|
||||
fn png_decode_u8_plane(bytes: &[u8]) -> Vec<u8> {
|
||||
let mut decoder = png::Decoder::new(Cursor::new(bytes)).read_info().expect("png read_info");
|
||||
let mut decoder = png::Decoder::new(Cursor::new(bytes))
|
||||
.read_info()
|
||||
.expect("png read_info");
|
||||
let mut buf = vec![0u8; decoder.output_buffer_size()];
|
||||
let frame = decoder.next_frame(&mut buf).expect("png next_frame");
|
||||
buf[..frame.buffer_size()].to_vec()
|
||||
@@ -436,7 +443,8 @@ fn encode_png(canvas: &WireCanvas) -> (Vec<u8>, std::time::Duration, std::time::
|
||||
let moisture_q_d = png_decode_u8_plane(&moisture_q_png);
|
||||
let vegetation_d = png_decode_u8_plane(&vegetation_png);
|
||||
let glaciation_d = png_decode_u8_plane(&glaciation_png);
|
||||
let temp_dc_d: Vec<i16> = rmp_serde::from_slice(&temp_dc_bytes).expect("rmp_serde decode temp_dc");
|
||||
let temp_dc_d: Vec<i16> =
|
||||
rmp_serde::from_slice(&temp_dc_bytes).expect("rmp_serde decode temp_dc");
|
||||
let dec_time = t1.elapsed();
|
||||
std::hint::black_box((
|
||||
morphology_d.len(),
|
||||
@@ -504,7 +512,8 @@ fn encode_png_of_bitpacked(
|
||||
let moisture_q_d = unpack_bits(&png_decode_u8_plane(&moisture_q_png), 7, n);
|
||||
let vegetation_d = unpack_bits(&png_decode_u8_plane(&vegetation_png), 3, n);
|
||||
let glaciation_d = unpack_bits(&png_decode_u8_plane(&glaciation_png), 3, n);
|
||||
let temp_dc_d: Vec<i16> = rmp_serde::from_slice(&temp_dc_bytes).expect("rmp_serde decode temp_dc");
|
||||
let temp_dc_d: Vec<i16> =
|
||||
rmp_serde::from_slice(&temp_dc_bytes).expect("rmp_serde decode temp_dc");
|
||||
let dec_time = t1.elapsed();
|
||||
std::hint::black_box((
|
||||
morphology_d.len(),
|
||||
@@ -559,14 +568,19 @@ fn run_canvas_report(
|
||||
rows: u32,
|
||||
label: &str,
|
||||
) {
|
||||
println!("\n=== T-1179 wire-size table: {label} = {} gridunits ===", cols as u64 * rows as u64);
|
||||
println!(
|
||||
"\n=== T-1179 wire-size table: {label} = {} gridunits ===",
|
||||
cols as u64 * rows as u64
|
||||
);
|
||||
|
||||
let (canvas, derive_time) = derive_canvas(seed, params, ta, cols, rows);
|
||||
println!(
|
||||
" derive: {:.2} ms ({} cells, {} Rayon threads available)\n",
|
||||
derive_time.as_secs_f64() * 1000.0,
|
||||
canvas.morphology.len(),
|
||||
std::thread::available_parallelism().map(|n| n.get()).unwrap_or(0)
|
||||
std::thread::available_parallelism()
|
||||
.map(|n| n.get())
|
||||
.unwrap_or(0)
|
||||
);
|
||||
|
||||
let (rmp_bytes, rmp_enc, rmp_dec) = encode_rmp(&canvas);
|
||||
|
||||
Reference in New Issue
Block a user