From 77731b4909c12fae2fa47469335f986f0180640e Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 26 Jun 2015 23:59:13 +0000 Subject: [PATCH] COFF: Use vector::erase instead of reallocating entire vector. NFC. llvm-svn: 240862 --- lld/COFF/Driver.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 2529446..f67de4c 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -485,17 +485,17 @@ bool LinkerDriver::link(llvm::ArrayRef ArgsArr) { // Windows specific -- Input files can be Windows resource files (.res files). // We invoke cvtres.exe to convert resource files to a regular COFF file // then link the result file normally. - auto IsResource = [](MemoryBufferRef MB) { - return identify_magic(MB.getBuffer()) == file_magic::windows_resource; + auto NotResource = [](MemoryBufferRef MB) { + return identify_magic(MB.getBuffer()) != file_magic::windows_resource; }; - auto It = std::stable_partition(Inputs.begin(), Inputs.end(), IsResource); - if (It != Inputs.begin()) { - std::vector Files(Inputs.begin(), It); + auto It = std::stable_partition(Inputs.begin(), Inputs.end(), NotResource); + if (It != Inputs.end()) { + std::vector Files(It, Inputs.end()); auto MBOrErr = convertResToCOFF(Files); if (MBOrErr.getError()) return false; std::unique_ptr MB = std::move(MBOrErr.get()); - Inputs = std::vector(It, Inputs.end()); + Inputs.erase(It, Inputs.end()); Inputs.push_back(MB->getMemBufferRef()); OwningMBs.push_back(std::move(MB)); // take ownership } -- 2.7.4