Replaced redundant .map with .for_each
This commit is contained in:
parent
a8d9c89da2
commit
bef3ddef50
@ -107,9 +107,7 @@ impl Level {
|
||||
chunks: Vec<ChunkCoordinates>,
|
||||
channel: mpsc::Sender<(ChunkCoordinates, Result<ChunkData, WorldError>)>,
|
||||
) {
|
||||
chunks
|
||||
.into_par_iter()
|
||||
.map(|chunk| {
|
||||
chunks.into_par_iter().for_each(|chunk| {
|
||||
let region = (
|
||||
((chunk.x as f32) / 32.0).floor() as i32,
|
||||
((chunk.z as f32) / 32.0).floor() as i32,
|
||||
@ -128,8 +126,8 @@ impl Level {
|
||||
return;
|
||||
}
|
||||
_ => {
|
||||
let _ = channel
|
||||
.blocking_send((chunk, Err(WorldError::IoError(err.kind()))));
|
||||
let _ =
|
||||
channel.blocking_send((chunk, Err(WorldError::IoError(err.kind()))));
|
||||
return;
|
||||
}
|
||||
},
|
||||
@ -143,16 +141,16 @@ impl Level {
|
||||
match region_file.read_exact(&mut location_table) {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
let _ = channel
|
||||
.blocking_send((chunk, Err(WorldError::IoError(err.kind()))));
|
||||
let _ =
|
||||
channel.blocking_send((chunk, Err(WorldError::IoError(err.kind()))));
|
||||
return;
|
||||
}
|
||||
}
|
||||
match region_file.read_exact(&mut timestamp_table) {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
let _ = channel
|
||||
.blocking_send((chunk, Err(WorldError::IoError(err.kind()))));
|
||||
let _ =
|
||||
channel.blocking_send((chunk, Err(WorldError::IoError(err.kind()))));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -165,9 +163,8 @@ impl Level {
|
||||
let table_entry = (chunk_x + chunk_z * 32) * 4;
|
||||
|
||||
let mut offset = vec![0u8];
|
||||
offset.extend_from_slice(
|
||||
&location_table[table_entry as usize..table_entry as usize + 3],
|
||||
);
|
||||
offset
|
||||
.extend_from_slice(&location_table[table_entry as usize..table_entry as usize + 3]);
|
||||
let offset = u32::from_be_bytes(offset.try_into().unwrap()) as u64 * 4096;
|
||||
let size = location_table[table_entry as usize + 3] as usize * 4096;
|
||||
|
||||
@ -225,7 +222,6 @@ impl Level {
|
||||
.blocking_send((chunk, ChunkData::from_bytes(decompressed_chunk, chunk)))
|
||||
.expect("Error sending decompressed chunk");
|
||||
})
|
||||
.collect::<Vec<()>>();
|
||||
}
|
||||
|
||||
fn decompress_data(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user