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