Current approach
- copy accumulated
retvector toarrTmp - drop unnecessary elements from
arrTmp - reverse
arrTmp - clear
ret - copy
arrTmpto theret
New approach
- create a vector from the accumulated
retwith just the necessary elements already reversed - copy it to the result
This PR doesn't change behavior.