10.2.1.2   Optimization

Optimization might be necessary for variables of class HTuple. This kind of optimization can either be done in HDevelop or in the generated C++ code. In most cases optimization is not necessary if you program according to the following rules.

  1. Using the tuple concatenation, it is more efficient to extend a tuple at the “right” side, like:

      T := [T,New]
    

    because this can be transformed to

      T = T.TupleConcat(New);
    

    in C++ and requires no creation of a new tuple, whereas

      T := [New,T]
    

    which is translated into

      T = HTuple(New).TupleConcat(T);
    

    would need the creation of a new tuple.

  2. Another good way to modify a tuple is the operator assign_at (see section “Assignment”). In this case HDevelop code like

      T[i] := New
    

    can directly be translated into the efficient and similar looking code

      T[i] = New;