|
@@ -52,16 +52,12 @@ impl IndexMut<&Point<u64>> for Chunk {
|
|
impl Chunk {
|
|
impl Chunk {
|
|
pub fn new() -> Self {
|
|
pub fn new() -> Self {
|
|
let mut s = Self { tiles: Vec::with_capacity(1024) };
|
|
let mut s = Self { tiles: Vec::with_capacity(1024) };
|
|
- for _ in 0..1024 {
|
|
|
|
- s.tiles.push(0);
|
|
|
|
- }
|
|
|
|
|
|
+ s.tiles.extend_from_slice(&[0u64; 1024]);
|
|
s
|
|
s
|
|
}
|
|
}
|
|
pub fn new_filled(value: u64) -> Self {
|
|
pub fn new_filled(value: u64) -> Self {
|
|
let mut s = Self { tiles: Vec::with_capacity(1024) };
|
|
let mut s = Self { tiles: Vec::with_capacity(1024) };
|
|
- for _ in 0..1024 {
|
|
|
|
- s.tiles.push(value);
|
|
|
|
- }
|
|
|
|
|
|
+ s.tiles.extend_from_slice(&[value; 1024]);
|
|
s
|
|
s
|
|
}
|
|
}
|
|
pub fn get(&self, pos: &Point<u64>) -> Option<&u64> {
|
|
pub fn get(&self, pos: &Point<u64>) -> Option<&u64> {
|
|
@@ -109,6 +105,7 @@ impl Chunk {
|
|
}
|
|
}
|
|
pub fn clear(&mut self) {
|
|
pub fn clear(&mut self) {
|
|
self.tiles.clear();
|
|
self.tiles.clear();
|
|
|
|
+ self.tiles.extend_from_slice(&[0u64; 1024]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|