Because tgt is a reference parameter it is actually more efficient to assign to a local variable (which is then used in the loop below), and then assign it to the output parameter.