From b8e28abb97c37e0bef7a768016bdf1026871b8d0 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Fri, 25 Apr 2025 13:47:14 -0700 Subject: [PATCH] Fix clang-tidy performance-for-range-copy warnings --- .clang-tidy | 1 + src/script_opt/ProfileFunc.cc | 2 +- src/script_opt/Stmt.cc | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index f3381a7b75..f80e93bce8 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,6 +3,7 @@ Checks: [-*, performance-avoid-endl, performance-enum-size, performance-faster-string-find, + performance-for-range-copy, # Skipping these temporarily because they are very noisy -bugprone-narrowing-conversions, diff --git a/src/script_opt/ProfileFunc.cc b/src/script_opt/ProfileFunc.cc index 64e85480d7..7a384a23e2 100644 --- a/src/script_opt/ProfileFunc.cc +++ b/src/script_opt/ProfileFunc.cc @@ -651,7 +651,7 @@ bool ProfileFuncs::HasSideEffects(SideEffectsOp::AccessType access, const TypePt bool ProfileFuncs::GetSideEffects(SideEffectsOp::AccessType access, const Type* t, IDSet& non_local_ids, TypeSet& aggrs) const { - for ( auto se : side_effects_ops ) + for ( const auto& se : side_effects_ops ) if ( AssessSideEffects(se.get(), access, t, non_local_ids, aggrs) ) return true; diff --git a/src/script_opt/Stmt.cc b/src/script_opt/Stmt.cc index 977e998864..ef5935b044 100644 --- a/src/script_opt/Stmt.cc +++ b/src/script_opt/Stmt.cc @@ -926,7 +926,7 @@ static bool simplify_chain(const std::vector& stmts, unsigned int start // At this point, chain_stmts has only the remainders that weren't removed. for ( auto s : stmts ) if ( chain_stmts.count(s.get()) > 0 ) - f_stmts.push_back(s); + f_stmts.push_back(std::move(s)); return true; }