elnabo / json2object

Type safe Haxe/JSON (de)serializer
MIT License
66 stars 17 forks source link

Output size #54

Closed Gama11 closed 5 years ago

Gama11 commented 5 years ago

When compiling haxe-language-server to JS, roughly 7 kLoC are json2object-generated JSON parsers, which seems a bit excessive:

https://gist.github.com/Gama11/d8552a31944553da1a43e06956844338

There seems to be quite a bit of duplicated code, for instance loadJsonArray() appears to be largely repeated for each parser dealing with arrays? Perhaps more code could be shared across parsers?

elnabo commented 5 years ago

I've started some optimisation of the generated code in aa8d4125b141d0d8122ca24d2de0ae347e1486df

As an example, parsing FormatterConfig of haxe-formatter in a simple example used to yield ~10k loc, the same example now yield ~7k. Some more optimisation are envisaged so I'm not closing this issue yet.

Gama11 commented 5 years ago

That's a nice improvement. :)

I wonder how size-efficient tink_json for instance is / if it's around the same size.

elnabo commented 5 years ago

No idea, but I assume it should produce significantly smaller files, since error logging takes a lot space.

ibilon commented 5 years ago

The parser for classes and anon has been changed, which gives another big reduction in size.

Arrays have yet to be improved.

Gama11 commented 5 years ago

Looks like the language server is already down to ~35 kLoC from previously ~41. :)

ibilon commented 5 years ago

Parsing an array now takes one line instead of ten (on js at least) which should help if you have a lot of arrays.