tools: avoid a string duplication

The auxiliary file records are contiguous and only contain the filename.
Construct a StringRef directly rather than copying to a temporary buffer.

Suggested by majnemer on IRC!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206139 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Saleem Abdulrasool 2014-04-13 22:54:11 +00:00
parent 42ad510d31
commit 1a16898813

View File

@ -695,14 +695,10 @@ static void PrintCOFFSymbolTable(const COFFObjectFile *coff) {
, unsigned(asd->Selection)); , unsigned(asd->Selection));
break; break;
case COFF::IMAGE_SYM_CLASS_FILE: case COFF::IMAGE_SYM_CLASS_FILE:
SmallString<261> FileName; const coff_aux_file *AF;
for (unsigned AI = i, AE = i + aux_count + 1; AI < AE; ++AI) { if (error(coff->getAuxSymbol<coff_aux_file>(i, AF)))
const coff_aux_file *AF; return;
if (error(coff->getAuxSymbol<coff_aux_file>(AI, AF))) outs() << "AUX " << StringRef(AF->FileName) << '\n';
return;
FileName.append(&AF->FileName[0], &AF->FileName[18]);
}
outs() << "AUX " << FileName << '\n';
i = i + aux_count; i = i + aux_count;
aux_count = 0; aux_count = 0;
break; break;