Improvements

This commit is contained in:
xavo95 2025-01-12 19:28:45 +01:00
parent bc590d0502
commit 36e4b12934
Signed by: xavo95
GPG key ID: CBF8ADED6DEBB783

View file

@ -36,6 +36,20 @@ impl TArray {
} }
} }
pub fn capacity(&self) -> u32 {
self.cap
}
pub fn clear(&mut self, len: u32) -> Self {
if self.data_ptr != 0 && self.len > 0 {
let data = unsafe {
std::slice::from_raw_parts_mut(self.data_ptr as *mut u8, self.len)
};
data.fill(0);
self.len = 0;
}
}
#[inline(always)] #[inline(always)]
pub(crate) fn resize_grow(&mut self, count: Option<u32>) -> u32 { pub(crate) fn resize_grow(&mut self, count: Option<u32>) -> u32 {
let count = count.unwrap_or(1); let count = count.unwrap_or(1);