[llvm] r264383 - StringMap: reserve appropriate size when initializing from an initializer list

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 22:57:47 PDT 2016


Author: mehdi_amini
Date: Fri Mar 25 00:57:47 2016
New Revision: 264383

URL: http://llvm.org/viewvc/llvm-project?rev=264383&view=rev
Log:
StringMap: reserve appropriate size when initializing from an initializer list

From: Mehdi Amini <mehdi.amini at apple.com>

Modified:
    llvm/trunk/include/llvm/ADT/StringMap.h

Modified: llvm/trunk/include/llvm/ADT/StringMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=264383&r1=264382&r2=264383&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)
+++ llvm/trunk/include/llvm/ADT/StringMap.h Fri Mar 25 00:57:47 2016
@@ -233,7 +233,7 @@ public:
       Allocator(A) {}
 
   StringMap(std::initializer_list<std::pair<StringRef, ValueTy>> List)
-      : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {
+      : StringMapImpl(List.size(), static_cast<unsigned>(sizeof(MapEntryTy))) {
     for (const auto &P : List) {
       insert(P);
     }




More information about the llvm-commits mailing list