summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2018-11-19 11:41:22 -0800
committer Andreas Gampe <agampe@google.com> 2018-11-20 13:04:36 -0800
commit2a487eb89b67d7ff030368e4e4a6ed0a3ac39003 (patch)
treebedffc5f4ee16d07c957d06cdab5148c69bd6a56
parent875b4f26517ce215342746f07e41cda4c1991237 (diff)
ART: Fix performance-inefficient-vector-operation
Bug: 32619234 Test: m test-art-host Change-Id: I286e27424ac39c0fed308811dc3004e734c0560c
-rw-r--r--dex2oat/dex2oat.cc1
-rw-r--r--dexoptanalyzer/dexoptanalyzer.cc1
-rw-r--r--profman/profman.cc1
-rw-r--r--runtime/oat_file_manager.cc6
-rw-r--r--tools/hiddenapi/hiddenapi.cc1
5 files changed, 9 insertions, 1 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 12a8354007..437bf368bd 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -115,6 +115,7 @@ static char** original_argv;
static std::string CommandLine() {
std::vector<std::string> command;
+ command.reserve(original_argc);
for (int i = 0; i < original_argc; ++i) {
command.push_back(original_argv[i]);
}
diff --git a/dexoptanalyzer/dexoptanalyzer.cc b/dexoptanalyzer/dexoptanalyzer.cc
index 21cdcf1313..2b97fb402a 100644
--- a/dexoptanalyzer/dexoptanalyzer.cc
+++ b/dexoptanalyzer/dexoptanalyzer.cc
@@ -52,6 +52,7 @@ static char** original_argv;
static std::string CommandLine() {
std::vector<std::string> command;
+ command.reserve(original_argc);
for (int i = 0; i < original_argc; ++i) {
command.push_back(original_argv[i]);
}
diff --git a/profman/profman.cc b/profman/profman.cc
index 734cdf498e..2935a05b48 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -60,6 +60,7 @@ static char** original_argv;
static std::string CommandLine() {
std::vector<std::string> command;
+ command.reserve(original_argc);
for (int i = 0; i < original_argc; ++i) {
command.push_back(original_argv[i]);
}
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 7ac1ab40a2..2c882ece05 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -118,9 +118,10 @@ const OatFile* OatFileManager::FindOpenedOatFileFromOatLocationLocked(
}
std::vector<const OatFile*> OatFileManager::GetBootOatFiles() const {
- std::vector<const OatFile*> oat_files;
std::vector<gc::space::ImageSpace*> image_spaces =
Runtime::Current()->GetHeap()->GetBootImageSpaces();
+ std::vector<const OatFile*> oat_files;
+ oat_files.reserve(image_spaces.size());
for (gc::space::ImageSpace* image_space : image_spaces) {
oat_files.push_back(image_space->GetOatFile());
}
@@ -153,6 +154,7 @@ OatFileManager::~OatFileManager() {
std::vector<const OatFile*> OatFileManager::RegisterImageOatFiles(
const std::vector<gc::space::ImageSpace*>& spaces) {
std::vector<const OatFile*> oat_files;
+ oat_files.reserve(spaces.size());
for (gc::space::ImageSpace* space : spaces) {
oat_files.push_back(RegisterOatFile(space->ReleaseOatFile()));
}
@@ -290,10 +292,12 @@ static bool CheckClassCollision(const OatFile* oat_file,
// Generate type index information for each dex file.
std::vector<TypeIndexInfo> loaded_types;
+ loaded_types.reserve(dex_files_loaded.size());
for (const DexFile* dex_file : dex_files_loaded) {
loaded_types.push_back(TypeIndexInfo(dex_file));
}
std::vector<TypeIndexInfo> unloaded_types;
+ unloaded_types.reserve(dex_files_unloaded.size());
for (const DexFile* dex_file : dex_files_unloaded) {
unloaded_types.push_back(TypeIndexInfo(dex_file));
}
diff --git a/tools/hiddenapi/hiddenapi.cc b/tools/hiddenapi/hiddenapi.cc
index 65a4945355..2f016e9d8a 100644
--- a/tools/hiddenapi/hiddenapi.cc
+++ b/tools/hiddenapi/hiddenapi.cc
@@ -39,6 +39,7 @@ static char** original_argv;
static std::string CommandLine() {
std::vector<std::string> command;
+ command.reserve(original_argc);
for (int i = 0; i < original_argc; ++i) {
command.push_back(original_argv[i]);
}