Anders429 / Anders429/brood

`component::Columns` struct

Offen
#66 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
A - Storage C - Enhancement P - Low S - Needs Investigation
Vorherrschende Sprache
Rust
Sterne
41
Forks
2
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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` 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::::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::Identifier`s, etc. When iterating, a `component::Column` type could be returned which allows for unsafe casting to a `Vec` 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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.