Implement a fast enough data component. - #1105
Conversation
7648957 to
2c50b53
Compare
2c50b53 to
55b06e9
Compare
|
imo the exception messages here could really use some work |
microlith57
left a comment
There was a problem hiding this comment.
apologies for the late review.
i strongly dislike this; it feels brittle and likely to cause difficult-to-diagnose issues later. perhaps this could be resolved by more thorough safety justification and better error messages, but i am still reluctant to introduce this risk into the codebase without good reason.
note that tools like ConditionalWeakTable are already available; is there a compelling reason why this is insufficient? are you able to measure the performance of this implementation in comparison to CWT? (and, if this is indeed more performant, is that benefit sufficient to justify the risks?)
55b06e9 to
f2daed2
Compare
|
a) It's not fragile. b) As an instance field, it works better with speedrun tool; And as a simple array, it doesn't introduce any DependentHandles and ConcurrentDictionaries. c) Benchmark shows that
d) wait, am i responding to your question or change as requested? |
I'm not too glad with the current way to attach fields to an entity.
DynamicData.ForandComponentare both slow (to me).That's why I made this. Why has no one ever done this before?
Advantage
Fast.
Implementation
Now
Entityholds a two-dimensional array. It stores all attached fields.The first dimension stands for the depth of the entity in the inheritance tree.
Users can register their fields to a type, and the second dimension is the unique index they got.
Any fields are attached to only one type (and it's subtype), it can't work as a universal component.
It handles inheritance by depth dimension. Any child entity will be able to access fields attached to the parent entity, naturally.
Any type safe issue is done by hidding the implementation details.