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/TrimTask.cpp b/TrimTask.cpp
index d7bfda7..6c141f2 100644
--- a/TrimTask.cpp
+++ b/TrimTask.cpp
@@ -53,7 +53,7 @@
VolumeManager* vm = VolumeManager::Instance();
std::list<std::string> privateIds;
vm->listVolumes(VolumeBase::Type::kPrivate, privateIds);
- for (auto id : privateIds) {
+ for (const auto& id : privateIds) {
auto vol = vm->findVolume(id);
if (vol != nullptr && vol->getState() == VolumeBase::State::kMounted) {
mPaths.push_back(vol->getPath());
@@ -114,7 +114,7 @@
void TrimTask::run() {
acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
- for (auto path : mPaths) {
+ for (const auto& path : mPaths) {
LOG(DEBUG) << "Starting trim of " << path;
int fd = open(path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);