c2lang / c2compiler

the c2 programming language
c2lang.org
Apache License 2.0
704 stars 49 forks source link

Use of std::vector, std::map/std::unordered_map #101

Open lerno opened 5 years ago

lerno commented 5 years ago

This is related to #100 which usually occurs together with STL usage.

In my research std::unordered_map/std::map are not very efficient for the special cases we want to use them for. Consequently hash maps could be replaced by simpler replacements reducing compilation time and increasing efficiency.

bvdberg commented 5 years ago

do you have specific instances which you want to replace?

lerno commented 5 years ago

@bvdberg Well, the glaring problem is in the parsing code, but creating a custom hash and vector could then be reused across the codebase I think. Note that llvm's implementations like smallvector (allocates the vector on the stack unless it grows large – ideal for when collecting a list of attributes etc that is known to be small in the common case) can probably be a good alternative to rolling ones own alternatives.