Array Index Notation
Avoid using the [n]
notation, myRef.Data[n]
for
example, to refer to repeating tree elements in a loop. This is particularly
bad practice if the number of elements in the list is large. When
you reference an element in this way, the elements are traversed in
sequence, starting from 1, until n is reached for every iteration
of the loop. Instead, use a reference variable and the MOVE NEXTSIBLING
syntax.
For a loop of 100 elements, index access notation results in 5000 (50 x 100) element traversals instead of 100 with the MOVE statement (50 times more). For a larger list of 1000 elements, it is worse; 500000 (500 x 1000) traversals instead of 1000 (500 times more).