Use cmp match to replace if chain (comparison_chain)

This commit is contained in:
ice_iix 2020-07-02 17:58:12 -07:00
parent 476d46cac6
commit 9cfb686528
1 changed files with 18 additions and 13 deletions

View File

@ -25,6 +25,7 @@ use crate::types::hash::FNVHash;
use crate::types::{bit, nibble}; use crate::types::{bit, nibble};
use cgmath::prelude::*; use cgmath::prelude::*;
use flate2::read::ZlibDecoder; use flate2::read::ZlibDecoder;
use std::cmp::Ordering;
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::hash::BuildHasherDefault; use std::hash::BuildHasherDefault;
@ -1270,10 +1271,12 @@ impl Chunk {
} }
} }
let idx = ((z << 4) | x) as usize; let idx = ((z << 4) | x) as usize;
if self.heightmap[idx] < y as u8 { match self.heightmap[idx].cmp(&(y as u8)) {
Ordering::Less => {
self.heightmap[idx] = y as u8; self.heightmap[idx] = y as u8;
self.heightmap_dirty = true; self.heightmap_dirty = true;
} else if self.heightmap[idx] == y as u8 { }
Ordering::Equal => {
// Find a new lowest // Find a new lowest
for yy in 0..y { for yy in 0..y {
let sy = y - yy - 1; let sy = y - yy - 1;
@ -1285,6 +1288,8 @@ impl Chunk {
} }
self.heightmap_dirty = true; self.heightmap_dirty = true;
} }
Ordering::Greater => (),
}
true true
} }