HaxeFoundation / format

Various files formats support for Haxe
131 stars 59 forks source link

Library modernization with @:structInit #63

Closed Yanrishatum closed 7 years ago

Yanrishatum commented 7 years ago

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 around typedef and their performance for static targets is questionable as they based on Dynamic.

Proposal:
Use @:structInit whenever possible instead of typedefs or at least use them for targets where it would improve performance.

Pros:

Cons:

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.

ncannasse commented 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