[llvm-commits] [llvm] r153949 - /llvm/trunk/lib/VMCore/Metadata.cpp

Benjamin Kramer benny.kra at googlemail.com
Tue Apr 3 03:57:02 PDT 2012


On 03.04.2012, at 12:50, Bill Wendling wrote:

> Author: void
> Date: Tue Apr  3 05:50:09 2012
> New Revision: 153949
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=153949&view=rev
> Log:
> Reserve space for the eventual filling of the vector. This gives a small speedup.
> 
> Modified:
>    llvm/trunk/lib/VMCore/Metadata.cpp
> 
> Modified: llvm/trunk/lib/VMCore/Metadata.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=153949&r1=153948&r2=153949&view=diff
> ==============================================================================
> --- llvm/trunk/lib/VMCore/Metadata.cpp (original)
> +++ llvm/trunk/lib/VMCore/Metadata.cpp Tue Apr  3 05:50:09 2012
> @@ -551,17 +551,16 @@
>          getContext().pImpl->MetadataStore.count(this) &&
>          "Shouldn't have called this");
>   const LLVMContextImpl::MDMapTy &Info =
> -  getContext().pImpl->MetadataStore.find(this)->second;
> +    getContext().pImpl->MetadataStore.find(this)->second;
>   assert(!Info.empty() && "Shouldn't have called this");
> -  
> +  Result.reserve(Info.size());
>   Result.append(Info.begin(), Info.end());

SmallVector::append should grow the vector only once with the exact size, making the reserve call unnecessary. If it grows more than once that's a bug in SmallVector.

- Ben
> -  
> +
>   // Sort the resulting array so it is stable.
>   if (Result.size() > 1)
>     array_pod_sort(Result.begin(), Result.end());
> }
> 
> -
> /// clearMetadataHashEntries - Clear all hashtable-based metadata from
> /// this instruction.
> void Instruction::clearMetadataHashEntries() {
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list