[cfe-commits] r74205 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp

Chris Lattner clattner at apple.com
Mon Jun 29 23:14:52 PDT 2009


On Jun 29, 2009, at 11:00 PM, Chris Lattner wrote:

>>
>> +  for (CXXRecordDecl::base_class_iterator Base = ClassDecl-
>>> bases_begin();
>> +       Base != ClassDecl->bases_end(); ++Base) {
>
> You've been learning from Doug very well I see :).  The problem with
> this loop is that it evaluates ClassDecl->bases_end() every time
> through the loop.  In cases where the end iterator isn't changing (the
> container isn't being mutated by the loop), it is better to compute it
> once and refer to the pre-computed value.

Since this is a common issue that a lot of people run into, I added it  
with some more explanation here:
http://llvm.org/docs/CodingStandards.html#ll_end

-Chris



More information about the cfe-commits mailing list