From 17fcdd5e1b78b829068ca657c97357a39d6e768b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 17 Apr 2007 03:26:42 +0000 Subject: Refactor SymbolTableListTraits to only have a single pointer in it, instead of two. This shrinkifies Function by 8 bytes (104->96) and Module by 8 bytes (68->60). On a testcase of mine, this reduces the memory used to read a module header from 565680b to 561024, a little over 4K. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36188 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/SymbolTableListTraits.h | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'include/llvm/SymbolTableListTraits.h') diff --git a/include/llvm/SymbolTableListTraits.h b/include/llvm/SymbolTableListTraits.h index 969c03fc55..099cfe0ca7 100644 --- a/include/llvm/SymbolTableListTraits.h +++ b/include/llvm/SymbolTableListTraits.h @@ -31,24 +31,17 @@ template class ilist_iterator; template class iplist; template struct ilist_traits; -// ValueSubClass - The type of objects that I hold -// ItemParentType - I call setParent() on all of my "ValueSubclass" items, and -// this is the value that I pass in. -// SymTabType - This is the class type, whose symtab I insert my -// ValueSubClass items into. Most of the time it is -// ItemParentType, but Instructions have item parents of BB's -// but symtabtype's of a Function +// ValueSubClass - The type of objects that I hold, e.g. Instruction. +// ItemParentType - The type of object that owns the list, e.g. BasicBlock. +// TraitBaseClass - The class this trait should inherit from, it should +// inherit from ilist_traits // -template > +template class SymbolTableListTraits { - SymTabClass *SymTabObject; + typedef ilist_traits TraitsClass; ItemParentClass *ItemParent; public: - SymbolTableListTraits() : SymTabObject(0), ItemParent(0) {} - - SymTabClass *getParent() { return SymTabObject; } - const SymTabClass *getParent() const { return SymTabObject; } + SymbolTableListTraits() : ItemParent(0) {} static ValueSubClass *getPrev(ValueSubClass *V) { return V->getPrev(); } static ValueSubClass *getNext(ValueSubClass *V) { return V->getNext(); } @@ -68,10 +61,10 @@ public: ilist_traits > &L2, ilist_iterator first, ilist_iterator last); - //private: - void setItemParent(ItemParentClass *IP) { ItemParent = IP; }//This is private! - void setParent(SymTabClass *Parent); // This is private! + void setItemParent(ItemParentClass *IP) { ItemParent = IP; } + template + void setSymTabObject(TPtr *, TPtr); }; } // End llvm namespace -- cgit v1.2.3