[llvm-commits] [llvm] r77461 - in /llvm/trunk: include/llvm/Support/FormattedStream.h lib/Support/FormattedStream.cpp

David Greene dag at cray.com
Wed Jul 29 13:04:01 PDT 2009


On Wednesday 29 July 2009 11:48, Andreas Bolka wrote:

> > +  while (Scanned != end()) {
>
> Please move the `end()` out of the loop or add a comment if it's really
> needed there (cf. http://llvm.org/docs/CodingStandards.html#ll_end).

I agree in some cases that end() can be heavyweight.  In this case it is not 
(it's a return of a pointer which will get inlined into a direct compare).  
All moving end() would do is obfuscate the code.

And I've been bitten by this particular rule many times where people *think*
they can move end() when they really can't because the loop inserts things
into the container and invalidates the saved value of end().

Coding standards shouldn't be hammers.  Especially when there aren't any
nails around.

                                 -Dave



More information about the llvm-commits mailing list