r371637 - [Clang][Bundler] Replace std::vector by SmallVector [NFC]
Sergey Dmitriev via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 11 09:28:47 PDT 2019
Author: sdmitriev
Date: Wed Sep 11 09:28:47 2019
New Revision: 371637
URL: http://llvm.org/viewvc/llvm-project?rev=371637&view=rev
Log:
[Clang][Bundler] Replace std::vector by SmallVector [NFC]
Differential Revision: https://reviews.llvm.org/D67413
Modified:
cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=371637&r1=371636&r2=371637&view=diff
==============================================================================
--- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original)
+++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Wed Sep 11 09:28:47 2019
@@ -17,6 +17,7 @@
#include "clang/Basic/Version.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
@@ -41,7 +42,6 @@
#include <memory>
#include <string>
#include <system_error>
-#include <vector>
using namespace llvm;
using namespace llvm::object;
@@ -658,10 +658,8 @@ static bool BundleFiles() {
}
// Open input files.
- std::vector<std::unique_ptr<MemoryBuffer>> InputBuffers(
- InputFileNames.size());
-
- unsigned Idx = 0;
+ SmallVector<std::unique_ptr<MemoryBuffer>, 8u> InputBuffers;
+ InputBuffers.reserve(InputFileNames.size());
for (auto &I : InputFileNames) {
ErrorOr<std::unique_ptr<MemoryBuffer>> CodeOrErr =
MemoryBuffer::getFileOrSTDIN(I);
@@ -669,7 +667,7 @@ static bool BundleFiles() {
errs() << "error: Can't open file " << I << ": " << EC.message() << "\n";
return true;
}
- InputBuffers[Idx++] = std::move(CodeOrErr.get());
+ InputBuffers.emplace_back(std::move(CodeOrErr.get()));
}
// Get the file handler. We use the host buffer as reference.
More information about the cfe-commits
mailing list