clang-tidy: Enable performance-for-range-copy check
This check optimizes performance in C++ for range-based loops
(for (auto element : container)), the key consideration is to
avoid unnecessary copies of elements, especially when dealing with
larger or more complex objects.
Change-Id: I3349630950f72e1c0365b2ab23b7858c1bfbc9d4
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/.clang-tidy b/.clang-tidy
index 3dcd93a..bbdad5d 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -215,6 +215,7 @@
misc-uniqueptr-reset-release,
misc-unused-using-decls,
performance-faster-string-find,
+performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-vector-operation,
diff --git a/test/utest.cpp b/test/utest.cpp
index 831d9b3..8e3edd3 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -408,7 +408,7 @@
TEST_F(FileTest, TestMergeFiles)
{
std::string retFile = tmpDir + "/retFile";
- for (auto file : srcFiles)
+ for (const auto& file : srcFiles)
{
command("cat " + file + " >> " + retFile);
}