Fix clang-tidy performance warnings in libfec.
* Use const reference type for for-loop index variables
to avoid unnecessary copy.
Bug: 30413223
Change-Id: I9819261087a5385fe580f805be44a2407f35cdf5
Test: build with WITH_TIDY=1
diff --git a/libfec/fec_verity.cpp b/libfec/fec_verity.cpp
index 393e962..5dea53d 100644
--- a/libfec/fec_verity.cpp
+++ b/libfec/fec_verity.cpp
@@ -349,7 +349,7 @@
auto tokens = android::base::Split(table.get(), " ");
- for (const auto token : tokens) {
+ for (const auto& token : tokens) {
switch (i++) {
case 0: /* version */
if (token != stringify(VERITY_TABLE_VERSION)) {
diff --git a/verity/fec/image.cpp b/verity/fec/image.cpp
index a378c93..610a462 100644
--- a/verity/fec/image.cpp
+++ b/verity/fec/image.cpp
@@ -290,7 +290,7 @@
std::vector<int> fds;
- for (auto fn : filenames) {
+ for (const auto& fn : filenames) {
int fd = TEMP_FAILURE_RETRY(open(fn.c_str(), flags | O_LARGEFILE));
if (fd < 0) {
diff --git a/verity/fec/main.cpp b/verity/fec/main.cpp
index 50d807e..0675fd6 100644
--- a/verity/fec/main.cpp
+++ b/verity/fec/main.cpp
@@ -189,7 +189,7 @@
size_t n = 1;
- for (auto fn : inp_filenames) {
+ for (const auto& fn : inp_filenames) {
INFO("\t%zu: '%s'\n", n++, fn.c_str());
}