Boolean Variant Optimization in Xojo
Did you know that Xojo runtime optimizes boolean variants?
Variants are used a lot with Dictionaries, Introspection and as RowTag/CellTag/ColumnTag in Listbox. They need to be fast.
Take an example code like this:
We check object count, create six local variables of type variant with assigning boolean values. Then we check object count again. What difference do you expect?
You may expect six, but the Xojo runtime actually optimizes this and returns the same two variants again and again. Beside the first two boolean variants created, there is no more memory used for variants. Think about that, when storing booleans in a dictionary or as a RowTag.
Even better would be if functions like the one used to create a boolean variant would be annotated, so LLVM could optimize away the calls above with the unused variables and give a difference of zero.