Performance improvements for C++ #1364
Labels
optimization
This increases performance or decreases size
rgbasm
This affects RGBASM
rgblink
This affects RGBLINK
Milestone
In the past few weeks we've been transitioning from C-style manual
malloc
andfree
(with over a dozen manuallyrealloc
ed collections, and known memory leaks in RGBASM, including some intentional ones essential to how it works) to C++-style STL generic (containers, algorithms, etc). This has in some cases reduced performance (particularly with older compilers).Some possibilities for optimization:
assume
instead ofassert
to allow optimizing out the failed-assertion case.reserve
an expected capacity for containers before filling them.std::move
d instead of copied when possible.std::visit
uses a table of function pointers in older compilers (try some in this example). We could just be sure to compile the release builds with more recent gcc/clang, but that still wouldn't help the popular Windows builds. We could also write our own solution to visit astd::variant
; there are many ways to do so (the linked example has some).variant
instead of aunion
and allowing tokens to have nontrivial constructors, significantly slows things down. We might be able to switch back to a C-style one and add manual allocation of nontrivial token values (plus%destructor
s).The text was updated successfully, but these errors were encountered: