COFF: Use vector::erase instead of reallocating entire vector. NFC.

llvm-svn: 240862
This commit is contained in:
Rui Ueyama 2015-06-26 23:59:13 +00:00
parent a07e1e7f2b
commit 77731b4909
1 changed files with 6 additions and 6 deletions

View File

@ -485,17 +485,17 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) {
// Windows specific -- Input files can be Windows resource files (.res files). // Windows specific -- Input files can be Windows resource files (.res files).
// We invoke cvtres.exe to convert resource files to a regular COFF file // We invoke cvtres.exe to convert resource files to a regular COFF file
// then link the result file normally. // then link the result file normally.
auto IsResource = [](MemoryBufferRef MB) { auto NotResource = [](MemoryBufferRef MB) {
return identify_magic(MB.getBuffer()) == file_magic::windows_resource; return identify_magic(MB.getBuffer()) != file_magic::windows_resource;
}; };
auto It = std::stable_partition(Inputs.begin(), Inputs.end(), IsResource); auto It = std::stable_partition(Inputs.begin(), Inputs.end(), NotResource);
if (It != Inputs.begin()) { if (It != Inputs.end()) {
std::vector<MemoryBufferRef> Files(Inputs.begin(), It); std::vector<MemoryBufferRef> Files(It, Inputs.end());
auto MBOrErr = convertResToCOFF(Files); auto MBOrErr = convertResToCOFF(Files);
if (MBOrErr.getError()) if (MBOrErr.getError())
return false; return false;
std::unique_ptr<MemoryBuffer> MB = std::move(MBOrErr.get()); std::unique_ptr<MemoryBuffer> MB = std::move(MBOrErr.get());
Inputs = std::vector<MemoryBufferRef>(It, Inputs.end()); Inputs.erase(It, Inputs.end());
Inputs.push_back(MB->getMemBufferRef()); Inputs.push_back(MB->getMemBufferRef());
OwningMBs.push_back(std::move(MB)); // take ownership OwningMBs.push_back(std::move(MB)); // take ownership
} }