Skip to content

Commit ead89d6

Browse files
authored
Clang-tidy CI test: add some performance checks in clang-tidy CI test (#4077)
* add some performance checks in clang-tidy CI test * fix few smalle performance issues found with clang-tidy * fix bug * fixed bug * fixed performance issue
1 parent f5917bf commit ead89d6

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

.clang-tidy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Checks: '-*,
99
modernize-use-nullptr,
1010
performance-faster-string-find,
1111
performance-for-range-copy,
12+
performance-implicit-conversion-in-loop,
13+
performance-inefficient-algorithm,
14+
performance-inefficient-string-concatenation,
15+
performance-inefficient-vector-operation,
1216
readability-non-const-parameter
1317
'
1418

Source/Diagnostics/Diagnostics.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ Diagnostics::BaseReadParameters ()
136136

137137
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
138138
parser_str != "",
139-
"Input error: cannot find parser string for " + var + " in file. "
140-
+ m_diag_name + ".particle_fields." + var + "(x,y,z,ux,uy,uz) is required"
141-
);
139+
std::string("Input error: cannot find parser string for ").append(var).append(" in file. ").append(
140+
m_diag_name).append(".particle_fields.").append(var).append("(x,y,z,ux,uy,uz) is required"));
142141

143142
m_pfield_strings.push_back(parser_str);
144143

@@ -189,7 +188,9 @@ Diagnostics::BaseReadParameters ()
189188
// Generate names of averaged particle fields and append to m_varnames
190189
for (const auto& fname : m_pfield_varnames) {
191190
for (const auto& sname : m_pfield_species) {
192-
m_varnames.push_back(fname + '_' + sname);
191+
auto varname = fname;
192+
varname.append("_").append(sname);
193+
m_varnames.push_back(varname);
193194
}
194195
}
195196

Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ FlushFormatCheckpoint::WriteDMaps (const std::string& dir, int nlev) const
211211
for (int lev = 0; lev < nlev; ++lev) {
212212
std::string DMFileName = dir;
213213
if (!DMFileName.empty() && DMFileName[DMFileName.size()-1] != '/') {DMFileName += '/';}
214-
DMFileName = amrex::Concatenate(DMFileName + "Level_", lev, 1);
214+
DMFileName = amrex::Concatenate(DMFileName.append("Level_"), lev, 1);
215215
DMFileName += "/DM";
216216

217217
std::ofstream DMFile;

Source/ablastr/utils/SignalHandling.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ SignalHandling::parseSignalNameToNumber (const std::string &str)
9595

9696
signals_parser.setConstant(name_upper, sp.value);
9797
signals_parser.setConstant(name_lower, sp.value);
98-
name_upper = "SIG" + name_upper;
99-
name_lower = "sig" + name_lower;
100-
signals_parser.setConstant(name_upper, sp.value);
101-
signals_parser.setConstant(name_lower, sp.value);
98+
const auto sig_name_upper = "SIG" + name_upper;
99+
const auto sig_name_lower = "sig" + name_lower;
100+
signals_parser.setConstant(sig_name_upper, sp.value);
101+
signals_parser.setConstant(sig_name_lower, sp.value);
102102
}
103103
#endif // #if defined(__linux__) || defined(__APPLE__)
104104

Source/ablastr/utils/msg_logger/MsgLogger.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ Logger::compute_msgs_with_counter_and_ranks(
353353
std::vector<MsgWithCounterAndRanks> msgs_with_counter_and_ranks;
354354

355355
// Put messages of the gather rank in msgs_with_counter_and_ranks
356+
msgs_with_counter_and_ranks.reserve(my_msg_map.size());
356357
for (const auto& el : my_msg_map)
357358
{
358359
msgs_with_counter_and_ranks.emplace_back(

0 commit comments

Comments
 (0)