Skip to content
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

component::Columns struct #66

Open
Anders429 opened this issue Mar 14, 2022 · 0 comments
Open

component::Columns struct #66

Anders429 opened this issue Mar 14, 2022 · 0 comments
Labels
A - Storage Area: Storage inside a World. C - Enhancement Category: New feature or request. P - Low Priority: Not particularly urgent. S - Needs Investigation Status: Further investigation is needed.

Comments

@Anders429
Copy link
Owner

It's a common pattern throughout all of the Registry trait functions to pass component columns along with a length, and in each method those raw values are used to create a Vec<C> for each component C specified by the archetype::Identifier. This is fine, but we end up with a lot of unsafe code being repeated in every single method. For example, in src/registry/seal/storage.rs, Vec::<C>::from_raw_parts is called 8 times, which is in 2/3rds of the functions provided in that module.

A component::Columns abstraction might help here. Rather than having to deal with the raw parts directly and risk mishandling them, the pointers, capacities, and shared len could be placed in a single struct that could handle indexing into it, iterating over it, getting entity::Identifiers, etc. When iterating, a component::Column type could be returned which allows for unsafe casting to a Vec<C> by simply providing the type to a method.

Some investigation will need to be done to ensure this actually will reduce complexity of the code. It may be difficult to actually reduce the complexity, and we don't want to make things more complicated by introducing more modules needlessly.

@Anders429 Anders429 added the C - Enhancement Category: New feature or request. label Mar 14, 2022
@Anders429 Anders429 added S - Needs Investigation Status: Further investigation is needed. P - Low Priority: Not particularly urgent. A - Storage Area: Storage inside a World. labels Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A - Storage Area: Storage inside a World. C - Enhancement Category: New feature or request. P - Low Priority: Not particularly urgent. S - Needs Investigation Status: Further investigation is needed.
Projects
None yet
Development

No branches or pull requests

1 participant