bevyengine / bevyengine/bevy

Suggestion: Rename `Table` and `SparseSet`

Open
#7,018 10 comments 4 reactions 0 assignees View on GitHub
A-ECS C-Code-Quality C-Usability
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Currently, we have two storage types for components:

```rust
pub enum StorageType {
/// Provides fast and cache-friendly iteration, but slower addition and removal of components.
/// This is the default storage type.
#[default]
Table,
/// Provides fast addition and removal of components, but slower iteration.
SparseSet,
}
```

Since `Table` is the default storage type, it's mostly hidden from the user, so it's less of an issue. However, I'd argue the name "Table" doesn't fully convey the intent of its usage. It mostly makes sense if the user is intimately familiar with the implementation details (in my opinion, at least).

The other type, `SparseSet`, would be used as such:
```rust
#[derive(Component)]
#[component(storage = "SparseSet")]
struct MySparseComponent;
```

While I do think the name `SparseSet` makes sense, I'd argue the suffix `Set` doesn't add any more information that isn't clearly expressed through the term `Sparse`.

## What solution would you like?

I propose `Dense` and `Sparse` would be better names for `Table` and `SparseSet` respectively.
In my mind, `Dense` is a much more appropriate description of how one might visualize `Table` components stored in memory.
And `Sparse` is just a more concise, but equally readable version of `SparseSet`, and opposite of `Dense`.

I'm open to alternative names, these are just the ones I think would work best.

## What alternative(s) have you considered?

N/A

## Additional context

To help with refactoring, I suggest the macro would still support `Table` and `SparseSet` with a deprecation warning.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.