Some minor optimization in chunk implementation
@@ -210,8 +210,9 @@ impl ChunkSection {
let old = self.block_at(x, y, z);
- if self.occurrence_map.contains_key(&old) && self.block_at(x, y, z) != old {
- let new_amnt = self.occurrence_map[&old] - 1;
+ if let Some(amnt) = self.occurrence_map.get(&old) {
+ if self.block_at(x, y, z) != old {
+ let new_amnt = amnt - 1;
if new_amnt == 0 {
self.occurrence_map.remove(&old);
@@ -220,6 +221,7 @@ impl ChunkSection {
self.occurrence_map.insert(old, new_amnt);
}
}
+ }
let amnt = self.occurrence_map.get(&block).cloned();
if let Some(amnt) = amnt {
