12% allocated memory savings when debugging clang with DWARF in .o files by

making sure we perfectly size our vector of symbols on the symbol table.

llvm-svn: 145069
This commit is contained in:
Greg Clayton 2011-11-22 18:47:24 +00:00
parent 8388955fd9
commit ddfda81ab8
2 changed files with 13 additions and 0 deletions

View File

@ -78,6 +78,16 @@ public:
static void DumpSymbolHeader (Stream *s);
void Finalize ()
{
// Shrink to fit the symbols so we don't waste memory
if (m_symbols.capacity() > m_symbols.size())
{
collection new_symbols (m_symbols.begin(), m_symbols.end());
m_symbols.swap (new_symbols);
}
}
protected:
typedef std::vector<Symbol> collection;
typedef collection::iterator iterator;

View File

@ -320,6 +320,7 @@ ObjectFileMachO::GetSymtab()
m_symtab_ap.reset(new Symtab(this));
Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
ParseSymtab (true);
m_symtab_ap->Finalize ();
}
return m_symtab_ap.get();
}
@ -1488,6 +1489,8 @@ ObjectFileMachO::ParseSymtab (bool minimize)
}
}
}
return symtab->GetNumSymbols();
}