Since the OpenLaszlo compiler does not do common-subexpression elimination, when you are trying to optimize things, pretend you are writing in 1985 C. Instead of:
Even better, when you find yourself having to write a null check, ask yourself if it would be cleaner, simpler, and more efficient to have the variable you are referencing not be nullable. For instance, if a variable is an array, consider using an empty array for its initial value, rather than null. This is a time/space trade-off: if there are many operations on the array and the variable is almost always not null, it will be more efficient to use an empty array; if there are few operations and the variable is usually null, then not allocating the empty array is the better choice.
Even though we don’t yet support the type declarations, we can follow the pattern and be ready…)
Post a comment