Skip to content

Commit 4f886ce

Browse files
author
Stephen Gutekanst
committed
clarify access of underlying MultiArrayList directly
Signed-off-by: Stephen Gutekanst <[email protected]>
1 parent bbe7d3a commit 4f886ce

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

content/2022/lets-build-ecs-part-2-databases.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,14 @@ Remember how I said earlier it was important that the mapping of table names ->
453453
const ptr: Pointer = entities.entities.get(entity_id).?;
454454
```
455455

456-
Now we know exactly which table and row it's stored in, and can lookup the table, or component values, which simple O(1) array access operations using the `ptr.archetype_index` and `ptr.row_index`, e.g.:
456+
Now we know exactly which table and row it's stored in, and can lookup the table, or component values, with simple O(1) array access operations. e.g. to get the archetype table the entity is stored in:
457457

458458
```zig
459459
var archetype = entities.archetypes.entries.get(ptr.archetype_index);
460460
```
461461

462+
Here, `entities.archetypes.entries` is our `AutoArrayHashMapUnmanaged` mapping table names to their `ArchetypeStorage` - but we access the array inside the hash map directly instead of using a hash map lookup.
463+
462464
## Creating an entity
463465

464466
<a class="imglink" href="https://user-images.githubusercontent.com/3173176/169890414-750717b6-f49d-4b9e-af82-08fcf5a663fe.png"><img src="https://user-images.githubusercontent.com/3173176/169889926-8872e7a0-8b98-4353-953f-8691a1b9f738.png"></a>

0 commit comments

Comments
 (0)