world/layer: replace iproduct!() with nested loops

iproduct!() is slow for more than 2 parameters.
This commit is contained in:
Matthias Schiffer 2023-03-02 01:00:55 +01:00
parent ed5fb9a6cf
commit 1d4c7a86ff
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -1,5 +1,4 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use itertools::iproduct;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::chunk::Chunk; use super::chunk::Chunk;
@ -98,11 +97,9 @@ pub fn top_layer(chunk: &Chunk) -> Result<Box<BlockInfoArray>> {
let mut done = 0; let mut done = 0;
let mut ret = Box::<BlockInfoArray>::default(); let mut ret = Box::<BlockInfoArray>::default();
for ((section_y, section), y, xz) in iproduct!( for (section_y, section) in chunk.sections().rev() {
chunk.sections().rev(), for y in BlockY::iter().rev() {
BlockY::iter().rev(), for xz in BlockInfoArray::keys() {
BlockInfoArray::keys()
) {
let entry = &mut ret[xz]; let entry = &mut ret[xz];
if entry.done() { if entry.done() {
continue; continue;
@ -124,6 +121,8 @@ pub fn top_layer(chunk: &Chunk) -> Result<Box<BlockInfoArray>> {
break; break;
} }
} }
}
}
Ok(ret) Ok(ret)
} }