feat: added pagination to the SparseSet to make it more memory efficient

This commit is contained in:
lisk77 2025-03-08 14:55:23 +01:00
parent a42ac5b8fd
commit ca3c3dd5e6
3 changed files with 57 additions and 29 deletions

View file

@ -5,7 +5,6 @@ use std::{
},
any::TypeId,
hash::{
DefaultHasher,
Hash,
Hasher
},
@ -14,6 +13,9 @@ use std::{
};
use std::ptr;
// The following two structs are just blatantly stolen from Bevy - another Rust game engine.
// I just need them for the ComponentStorage system, and I was too lazy to write them myself.
#[derive(Debug, Clone)]
pub struct BlobVec {
item_layout: Layout,
@ -24,7 +26,6 @@ pub struct BlobVec {
drop: unsafe fn(*mut u8)
}
impl BlobVec {
pub fn new(item_layout: Layout, drop: unsafe fn(*mut u8), capacity: usize) -> Self {
if item_layout.size() == 0 {
@ -84,7 +85,6 @@ impl BlobVec {
self.capacity = new_capacity;
}
#[inline]
pub fn len(&self) -> usize {
self.len