-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace SparseArray Option<T> with T::MAX to cut down on branching #1558
Comments
Cranelift has |
Ooh I dig that! |
Is it worth bringing in Also inorder to use pub struct SparseArray<I, V = I>
where
V: ReservedValue,
{
values: Vec<PackedOption<V>>,
marker: PhantomData<I>,
}
struct Wrapper<T>(T);
// ReservedValue is requires for PackedOptiont<T>
impl ReservedValue for Wrapper<usize> { /* impl */ }
pub struct ComponentSparseSet {
// ..fields
sparse: SparseArray<Entity, Wrapper<usize>>,
} |
The code is small enough that I think rolling our own is probably the move for maximum flexibility / keeping dep count low. Afaik Wrapper would get compiled out, so thats largely just a question of ergonomic right? |
Cool, this is the path I was planning on.
Yep, performance shouldn't be an issue. It was more so a code-cleanliness/ergonomic issue ahah :) |
This was implemented for non-component SparseSets for all ECS metadata stores (i.e. Resources, Tables, etc.) in #12083. ComponentSparseSet not supporting the full index range of entities will likely be a correctness error. Closing this out as completed. |
From Future Work of #1525.
The text was updated successfully, but these errors were encountered: