Fix clang-tidy performance warnings in system/vold.
* Use const reference type for for-loop index variables
to avoid unnecessary copy.
Bug: 30413223
Change-Id: Id4d980ae8afec1374fc3be0b23f1c6a39bff86e0
Test: build with WITH_TIDY=1
diff --git a/Disk.cpp b/Disk.cpp
index 920edab..f03f93d 100644
--- a/Disk.cpp
+++ b/Disk.cpp
@@ -106,7 +106,7 @@
}
void Disk::listVolumes(VolumeBase::Type type, std::list<std::string>& list) {
- for (auto vol : mVolumes) {
+ for (const auto& vol : mVolumes) {
if (vol->getType() == type) {
list.push_back(vol->getId());
}
@@ -179,7 +179,7 @@
}
void Disk::destroyAllVolumes() {
- for (auto vol : mVolumes) {
+ for (const auto& vol : mVolumes) {
vol->destroy();
}
mVolumes.clear();
@@ -268,7 +268,7 @@
Table table = Table::kUnknown;
bool foundParts = false;
- for (auto line : output) {
+ for (const auto& line : output) {
char* cline = (char*) line.c_str();
char* token = strtok(cline, kSgdiskToken);
if (token == nullptr) continue;
@@ -333,7 +333,7 @@
}
status_t Disk::unmountAll() {
- for (auto vol : mVolumes) {
+ for (const auto& vol : mVolumes) {
vol->unmount();
}
return OK;