Skip to content

Modify Variant CastAndCall to have fewer cases in its switch

Kenneth Moreland requested to merge kmorel/vtk-m:variant-fewer-cases into master

The previous implementation of Variant's CastAndCall generated a switch statement with 20 cases (plus a default) regardless of how many types were handled by the Variant (with the excess doing nothing useful). This reduced the amount of code, but caused the compiler to have to build many more instructions (and optimize for them). This in turn lead to large compile times and unnecessary large libraries/ executables.

This change makes a different function to use for CastAndCall so that the number of cases in the switch matches exactly the number of types in the Variant's union.

Because the size of VariantImplDetail.h was getting large, I also reduced the maximum expansions for the code. This does not seem to negatively affect compile time, and I doubt it will have an noticible difference in running time (when in release mode).

I also modified some other parts of this code to match the expansion without making unnecessary defaults.

Merge request reports