From a3b37f4d08e757ce90a7b02ca0e15951455c477c Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Wed, 27 Jul 2016 15:06:58 -0700 Subject: 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 --- libfec/fec_verity.cpp | 2 +- verity/fec/image.cpp | 2 +- verity/fec/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libfec/fec_verity.cpp b/libfec/fec_verity.cpp index 393e9624..5dea53dd 100644 --- a/libfec/fec_verity.cpp +++ b/libfec/fec_verity.cpp @@ -349,7 +349,7 @@ static int parse_table(fec_handle *f, uint64_t offset, uint32_t size) 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 a378c932..610a4627 100644 --- a/verity/fec/image.cpp +++ b/verity/fec/image.cpp @@ -290,7 +290,7 @@ bool image_load(const std::vector& filenames, image *ctx, std::vector 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 50d807e2..0675fd6c 100644 --- a/verity/fec/main.cpp +++ b/verity/fec/main.cpp @@ -189,7 +189,7 @@ static int encode(image& ctx, const std::vector& inp_filenames, size_t n = 1; - for (auto fn : inp_filenames) { + for (const auto& fn : inp_filenames) { INFO("\t%zu: '%s'\n", n++, fn.c_str()); } -- cgit v1.2.3