joerg added a comment. A better construct would be to compute the full length and change both it and Str in the loop. No point in the complex arithmetic. I generally do prefer this as it improves interaction with pipes etc. https://reviews.llvm.org/D35245