Consider the following code:
int *buff = new int[3];
for (int i =0; i<3; i++)
buff[i] = 0;
This loop is inefficient: 🙂
On every iteration, it assigns a value to the next array element. However,precious CPU time is also wasted on testing the counter and incrementing the counter’s value and performing a jump statement. To avoid this overhead, the compiler can unroll the loop into a sequence of three assignment statements, as follows:
buff[0] = 0;
buff[1] = 0;
buff[2] = 0;



If your actions inspire others to dream more, learn more, do more and become more, you are a leader