pure-c / purec

C backend for PureScript
232 stars 8 forks source link

Create structs for type classes #53

Open felixSchl opened 5 years ago

felixSchl commented 5 years ago

The current dictionary-based approach has poor performance because the dictionaries are frequently allocated and released, meaning that strings (keys) are frequently allocated and released as well. Considering that the dictionary is completely known a priori we might as well emit matching structs or use some purs_any_t ** and access them by some known pointer offset by key.

felixSchl commented 3 years ago

This comment still holds true in part, however, top-level thunks are now cached and only evaluated once during the program's runtime. Another idea I had to perhaps squeeze out a bit more performance improvements without relying on upstream support for this feature is to pre-hash the keys into the dictionary for generated code.