[llvm-commits] [llvm] r136492 - /llvm/trunk/utils/TableGen/Record.cpp

David Greene greened at obbligato.org
Fri Jul 29 12:07:15 PDT 2011


Author: greened
Date: Fri Jul 29 14:07:15 2011
New Revision: 136492

URL: http://llvm.org/viewvc/llvm-project?rev=136492&view=rev
Log:
[AVX] Make CodeInit Unique

Use a StringMap to ensure CodeInits are unique and created only
once.

Modified:
    llvm/trunk/utils/TableGen/Record.cpp

Modified: llvm/trunk/utils/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=136492&r1=136491&r2=136492&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Fri Jul 29 14:07:15 2011
@@ -575,7 +575,12 @@
 }
 
 const CodeInit *CodeInit::get(const std::string &V) {
-  return new CodeInit(V);
+  typedef StringMap<CodeInit *> Pool;
+  static Pool ThePool;
+
+  CodeInit *&I = ThePool[V];
+  if (!I) I = new CodeInit(V);
+  return I;
 }
 
 const ListInit *ListInit::get(ArrayRef<const Init *> Range, RecTy *EltTy) {





More information about the llvm-commits mailing list