void foo(struct bar array[], unsigned int count)
{
/* some initialization code */
for (int i = 0; i < count; i++) {
/* 30 rows of code
doing something with array[i]*/
}
for (int i = 0; i < count; i++) {
/* other 20 rows of code
doing something with array[i]*/
}
/* some cleanup code */
}
At first, I thought that, in the first loop, some data needed by the second loop were calculated. But after a closer look, I found that this was not the case. Furthermore, I saw that the first five or six rows of both loops were the same.The explanation is that the second loop has been added years later the first by a different developer that didn't want to waste time in understanding what the first loop did. You may not like it, but it works, unless you have performance issues. Personally, I think there are funnier ways to make two loops in a row.
![Coasterman1234 at en.wikipedia) [CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons Corkscrew (Cedar Point) 01](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWHILNnv9hIXrhyphenhypheni7cyEoSqe-OBGDZ_HVFgm6tf9TdHA3aO9ZtW7pGW_9qpTWE2BOezbSyqhSyUbeXYEU63VxPEXR_euzI28f6iW3QD_TQUFadmaDBiOsuT1ToP_KuazzDBQEEQLcglH4/s1600/Corkscrew_(Cedar_Point)_01.jpg)


Post a Comment