flatbuffers
flatbuffers copied to clipboard
[TS] In version 2, why do union helpers use string comparison?
In version 2, union helpers in the form of unionToAnyX are generated. Inside them, there is a switch of type:
switch(AnyX[type]) {
case 'NONE': return null;
...
}
Where type is the actual enum with variants defined as integers starting from 0. So, why not switching directly on type, like:
switch(type) {
case '0' /* NONE */: return null;
...
}
as the code is generated anyway?
Moreover, it might make sense to use const enums for performance reasons, if the added constraints on the API are acceptable.
@bjornharrtell
Will need to look into it more to see what would be good to do, but seems to be sound observations.
This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.
Commenting to avoid stale issue. I think this should be addressed.
For the record, unfortunately, I have no current plans to spend time on this myself.
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.
Commenting to avoid stale issue. Btw, as a user taking time to report bugs, I really do not like this idea of automatic issue closing, that feels like the ostrich approach to software development to me ;-P
@stephanemagnenat but sometimes problems do go away if you just ignore them for a while. :D
Seriously though, any help to improve the situation with unions would be appriecated but I still have no plans to invest time into it myself.
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.
comment to avoid staling
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.
comment to avoid staling