[cfe-commits] r49570 - in /cfe/trunk/lib/Sema: IdentifierResolver.cpp IdentifierResolver.h

Chris Lattner clattner at apple.com
Fri Apr 11 22:58:38 PDT 2008


On Apr 11, 2008, at 6:50 PM, Argiris Kirtzidis wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=49570&view=rev
> Log:
> Fixed comments.
> Moved IdDeclInfo class to anonymous namespace.
> Replaced array with a std::vector.

Nice, some more minor stuff:
> @@ -221,12 +221,14 @@
>     return *toIdDeclInfo(Ptr);
>   }
>
> +  if (CurIndex == VECTOR_SIZE) {
> +    // Add a IdDeclInfo vector 'pool'
> +    IDIVecs.resize(IDIVecs.size() + 1);

I believe this is O(n) on some std::list's.  I'd just use  
IDIVecs.push_back(std::vector<t>());  This is guaranteed constant time  
and is more idiomatic.

> +    // Fill the vector
> +    IDIVecs.back().resize(VECTOR_SIZE);

If you're using std::vector, why not just make this  
'reserve(VECTOR_SIZE)' and then use push_back when adding elements.   
This way, the vector keeps track of the size, instead of having to  
maintain CurIndex in parallel?

>   }
> +  IdDeclInfo *IDI = &IDIVecs.back()[CurIndex];

If you do that, this can just be push_back() + back().

>
-Chris



More information about the cfe-commits mailing list