component::Columns
struct
#66
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.
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 aVec<C>
for each component C specified by thearchetype::Identifier
. This is fine, but we end up with a lot of unsafe code being repeated in every single method. For example, insrc/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 sharedlen
could be placed in a single struct that could handle indexing into it, iterating over it, gettingentity::Identifier
s, etc. When iterating, acomponent::Column
type could be returned which allows for unsafe casting to aVec<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.
The text was updated successfully, but these errors were encountered: