]> granicus.if.org Git - clang/commitdiff
Remove unused Prev pointer from MacroInfo chain.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 24 Jul 2014 01:13:23 +0000 (01:13 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 24 Jul 2014 01:13:23 +0000 (01:13 +0000)
Remove pointless MICache: it only ever contained up to 1 object, and was only
non-empty when recovering from an error. There's no performance or memory win
from maintaining this cache.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213825 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/Preprocessor.h
lib/Lex/PPDirectives.cpp
lib/Lex/Preprocessor.cpp

index d4b4ba246961bea04f450e213b6cb91c410a0624..3686932fb3a2c457741f20ca69f80f3163283675 100644 (file)
@@ -433,17 +433,12 @@ private:  // Cached tokens state.
   struct MacroInfoChain {
     MacroInfo MI;
     MacroInfoChain *Next;
-    MacroInfoChain *Prev;
   };
 
   /// MacroInfos are managed as a chain for easy disposal.  This is the head
   /// of that list.
   MacroInfoChain *MIChainHead;
 
-  /// A "freelist" of MacroInfo objects that can be reused for quick
-  /// allocation.
-  MacroInfoChain *MICache;
-
   struct DeserializedMacroInfoChain {
     MacroInfo MI;
     unsigned OwningModuleID; // MUST be immediately after the MacroInfo object
index a8e27c71da824f9c6ed7c1e7666189455d6046dd..c38080f7159e4b6c8ac3ed9ad9acce5a7c298e10 100644 (file)
@@ -34,23 +34,10 @@ using namespace clang;
 //===----------------------------------------------------------------------===//
 
 MacroInfo *Preprocessor::AllocateMacroInfo() {
-  MacroInfoChain *MIChain;
-
-  if (MICache) {
-    MIChain = MICache;
-    MICache = MICache->Next;
-  }
-  else {
-    MIChain = BP.Allocate<MacroInfoChain>();
-  }
-
+  MacroInfoChain *MIChain = BP.Allocate<MacroInfoChain>();
   MIChain->Next = MIChainHead;
-  MIChain->Prev = nullptr;
-  if (MIChainHead)
-    MIChainHead->Prev = MIChain;
   MIChainHead = MIChain;
-
-  return &(MIChain->MI);
+  return &MIChain->MI;
 }
 
 MacroInfo *Preprocessor::AllocateMacroInfo(SourceLocation L) {
@@ -101,20 +88,6 @@ Preprocessor::AllocateVisibilityMacroDirective(SourceLocation Loc,
 /// \brief Release the specified MacroInfo to be reused for allocating
 /// new MacroInfo objects.
 void Preprocessor::ReleaseMacroInfo(MacroInfo *MI) {
-  MacroInfoChain *MIChain = (MacroInfoChain *)MI;
-  if (MacroInfoChain *Prev = MIChain->Prev) {
-    MacroInfoChain *Next = MIChain->Next;
-    Prev->Next = Next;
-    if (Next)
-      Next->Prev = Prev;
-  } else {
-    assert(MIChainHead == MIChain);
-    MIChainHead = MIChain->Next;
-    MIChainHead->Prev = nullptr;
-  }
-  MIChain->Next = MICache;
-  MICache = MIChain;
-
   MI->Destroy();
 }
 
index 4a11803aa9547ec05e7eb99964c130c11de31a64..963b7157164005d16f16125e7841b9c3ec529f2d 100644 (file)
@@ -70,7 +70,7 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts,
       SkipMainFilePreamble(0, true), CurPPLexer(nullptr),
       CurDirLookup(nullptr), CurLexerKind(CLK_Lexer), CurSubmodule(nullptr),
       Callbacks(nullptr), MacroArgCache(nullptr), Record(nullptr),
-      MIChainHead(nullptr), MICache(nullptr), DeserialMIChainHead(nullptr) {
+      MIChainHead(nullptr), DeserialMIChainHead(nullptr) {
   OwnsHeaderSearch = OwnsHeaders;
   
   ScratchBuf = new ScratchBuffer(SourceMgr);
@@ -142,7 +142,7 @@ Preprocessor::~Preprocessor() {
   IncludeMacroStack.clear();
 
   // Free any macro definitions.
-  for (MacroInfoChain *I = MIChainHead ; I ; I = I->Next)
+  for (MacroInfoChain *I = MIChainHead; I; I = I->Next)
     I->MI.Destroy();
 
   // Free any cached macro expanders.