Fix up a few minor performance problems spotted in code review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193023 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher 2013-10-19 01:04:42 +00:00
parent 7b79924dec
commit 0ab6439c3f

View File

@ -912,8 +912,7 @@ void CompileUnit::addAccelType(StringRef Name, std::pair<DIE *, unsigned> Die) {
/// addGlobalName - Add a new global name to the compile unit. /// addGlobalName - Add a new global name to the compile unit.
void CompileUnit::addGlobalName(StringRef Name, DIE *Die, DIScope Context) { void CompileUnit::addGlobalName(StringRef Name, DIE *Die, DIScope Context) {
std::string ContextString = getParentContextString(Context); std::string FullName = getParentContextString(Context) + Name.str();
std::string FullName = ContextString + Name.str();
GlobalNames[FullName] = Die; GlobalNames[FullName] = Die;
} }
@ -925,9 +924,9 @@ void CompileUnit::addGlobalType(DIType Ty) {
(!Context || Context.isCompileUnit() || Context.isFile() || (!Context || Context.isCompileUnit() || Context.isFile() ||
Context.isNameSpace())) Context.isNameSpace()))
if (DIEEntry *Entry = getDIEEntry(Ty)) { if (DIEEntry *Entry = getDIEEntry(Ty)) {
std::string ContextString = getParentContextString(Context); std::string FullName =
std::string FullName = ContextString + Ty.getName().str(); getParentContextString(Context) + Ty.getName().str();
GlobalTypes[FullName] = Entry->getEntry(); GlobalTypes[FullName] = Entry->getEntry();
} }
} }
@ -944,7 +943,7 @@ std::string CompileUnit::getParentContextString(DIScope Context) const {
if (getLanguage() != dwarf::DW_LANG_C_plus_plus) if (getLanguage() != dwarf::DW_LANG_C_plus_plus)
return ""; return "";
std::string CS = ""; std::string CS;
SmallVector<DIScope, 1> Parents; SmallVector<DIScope, 1> Parents;
while (!Context.isCompileUnit()) { while (!Context.isCompileUnit()) {
Parents.push_back(Context); Parents.push_back(Context);
@ -963,7 +962,7 @@ std::string CompileUnit::getParentContextString(DIScope Context) const {
I != E; ++I) { I != E; ++I) {
DIScope Ctx = *I; DIScope Ctx = *I;
StringRef Name = Ctx.getName(); StringRef Name = Ctx.getName();
if (Name != "") { if (!Name.empty()) {
CS += Name; CS += Name;
CS += "::"; CS += "::";
} }