On Mon, Apr 25, 2016 at 02:28:51PM +0200, Bernd Schmidt wrote: > On 04/20/2016 08:22 AM, tbsaunde+...@tbsaunde.org wrote: > >From: Trevor Saunders <tbsaunde+...@tbsaunde.org> > > >+ unsigned int len = cond_list.length (); > >+ for (unsigned int i = len - 1; i < len; i--) > > This is a really icky way to write a loop, the i < len condition makes it > look like a forward one. We have FOR_EACH_VEC_ELT{,_REVERSE}, any reason not > to use these?
I'll agree that depending on unsigned wrapping is a tad wierd, but personally I think FOR_EACH_VEC_* are pretty icky, and just forget to think about them before writing a loop. The vec::iterate () methods are a little slower than they need to be since they check the vector length each iteration instead of caching it (and pretty sure the compiler can't save you in a bunch of these places). Its Unfortunate you need to declare a temporary for the vector item, and worse that temporary can't be scoped by the loop. Finally it seems like more work to remember the order of arguments to FOR_EACH_VEC_ than just to write the loop. That all said if people really feel strongly and I'll grant consistancy matters I can try and change loops to use FOR_EACH_VEC_*. Trev > > > Bernd