Closed Yanrishatum closed 7 years ago
I think it would only work for typedefs that might been use a lot in the file format or which have a lot of fields accesses. If it's for the top level typedef's ("Data" type) that doesn't make much a difference.
I'll close the issue for now, please submit a PR if you wish to change some actual specific typedef by adding @:structInit
Since Haxe 3.4 there were implemented new feature for static structures -
@:structInit
which gives a lot better performance for static targets. Entire library is built aroundtypedef
and their performance for static targets is questionable as they based onDynamic
.Proposal:
Use
@:structInit
whenever possible instead of typedefs or at least use them for targets where it would improve performance.Pros:
Cons:
#if (haxever >= 3.4)
and/or target checks everywhere.Personal interest:
I extensively use my tmx format-like library and it's structure based on typedefs as well, but as we use C++ target, I do not like the overall performance during file processing, as I need it working as fast as possible because they need to be loaded realtime during gameplay. I wanted to rework library and do a pull request with it, but I do not like using typedefs for static targets.