r213825 - Remove unused Prev pointer from MacroInfo chain.
Richard Smith
richard-llvm at metafoo.co.uk
Wed Jul 23 18:13:23 PDT 2014
Author: rsmith
Date: Wed Jul 23 20:13:23 2014
New Revision: 213825
URL: http://llvm.org/viewvc/llvm-project?rev=213825&view=rev
Log:
Remove unused Prev pointer from MacroInfo chain.
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.
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=213825&r1=213824&r2=213825&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Jul 23 20:13:23 2014
@@ -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
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=213825&r1=213824&r2=213825&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Jul 23 20:13:23 2014
@@ -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::AllocateVisibilityMacroDir
/// \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();
}
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=213825&r1=213824&r2=213825&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Jul 23 20:13:23 2014
@@ -70,7 +70,7 @@ Preprocessor::Preprocessor(IntrusiveRefC
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.
More information about the cfe-commits
mailing list