aboutsummaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorGravatar Luca Fedeli <luca.fedeli@cea.fr> 2023-07-18 01:03:09 +0200
committerGravatar GitHub <noreply@github.com> 2023-07-17 16:03:09 -0700
commitead89d6b402d9323390f25a44f0bf100bba4083c (patch)
tree4d4b602aa8d87b25b418a4e4908d45d1acf58d05 /Source
parentf5917bf5dd42db01eb4aabf3459852b7bf1627a6 (diff)
downloadWarpX-ead89d6b402d9323390f25a44f0bf100bba4083c.tar.gz
WarpX-ead89d6b402d9323390f25a44f0bf100bba4083c.tar.zst
WarpX-ead89d6b402d9323390f25a44f0bf100bba4083c.zip
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
Diffstat (limited to 'Source')
-rw-r--r--Source/Diagnostics/Diagnostics.cpp9
-rw-r--r--Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp2
-rw-r--r--Source/ablastr/utils/SignalHandling.cpp8
-rw-r--r--Source/ablastr/utils/msg_logger/MsgLogger.cpp1
4 files changed, 11 insertions, 9 deletions
diff --git a/Source/Diagnostics/Diagnostics.cpp b/Source/Diagnostics/Diagnostics.cpp
index 8af5c24b9..b87e60fab 100644
--- a/Source/Diagnostics/Diagnostics.cpp
+++ b/Source/Diagnostics/Diagnostics.cpp
@@ -136,9 +136,8 @@ Diagnostics::BaseReadParameters ()
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
parser_str != "",
- "Input error: cannot find parser string for " + var + " in file. "
- + m_diag_name + ".particle_fields." + var + "(x,y,z,ux,uy,uz) is required"
- );
+ std::string("Input error: cannot find parser string for ").append(var).append(" in file. ").append(
+ m_diag_name).append(".particle_fields.").append(var).append("(x,y,z,ux,uy,uz) is required"));
m_pfield_strings.push_back(parser_str);
@@ -189,7 +188,9 @@ Diagnostics::BaseReadParameters ()
// Generate names of averaged particle fields and append to m_varnames
for (const auto& fname : m_pfield_varnames) {
for (const auto& sname : m_pfield_species) {
- m_varnames.push_back(fname + '_' + sname);
+ auto varname = fname;
+ varname.append("_").append(sname);
+ m_varnames.push_back(varname);
}
}
diff --git a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp
index eb011f7fb..6608123bb 100644
--- a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp
+++ b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp
@@ -211,7 +211,7 @@ FlushFormatCheckpoint::WriteDMaps (const std::string& dir, int nlev) const
for (int lev = 0; lev < nlev; ++lev) {
std::string DMFileName = dir;
if (!DMFileName.empty() && DMFileName[DMFileName.size()-1] != '/') {DMFileName += '/';}
- DMFileName = amrex::Concatenate(DMFileName + "Level_", lev, 1);
+ DMFileName = amrex::Concatenate(DMFileName.append("Level_"), lev, 1);
DMFileName += "/DM";
std::ofstream DMFile;
diff --git a/Source/ablastr/utils/SignalHandling.cpp b/Source/ablastr/utils/SignalHandling.cpp
index c34d760be..0fdbd834e 100644
--- a/Source/ablastr/utils/SignalHandling.cpp
+++ b/Source/ablastr/utils/SignalHandling.cpp
@@ -95,10 +95,10 @@ SignalHandling::parseSignalNameToNumber (const std::string &str)
signals_parser.setConstant(name_upper, sp.value);
signals_parser.setConstant(name_lower, sp.value);
- name_upper = "SIG" + name_upper;
- name_lower = "sig" + name_lower;
- signals_parser.setConstant(name_upper, sp.value);
- signals_parser.setConstant(name_lower, sp.value);
+ const auto sig_name_upper = "SIG" + name_upper;
+ const auto sig_name_lower = "sig" + name_lower;
+ signals_parser.setConstant(sig_name_upper, sp.value);
+ signals_parser.setConstant(sig_name_lower, sp.value);
}
#endif // #if defined(__linux__) || defined(__APPLE__)
diff --git a/Source/ablastr/utils/msg_logger/MsgLogger.cpp b/Source/ablastr/utils/msg_logger/MsgLogger.cpp
index 80787adc5..6b141c33b 100644
--- a/Source/ablastr/utils/msg_logger/MsgLogger.cpp
+++ b/Source/ablastr/utils/msg_logger/MsgLogger.cpp
@@ -353,6 +353,7 @@ Logger::compute_msgs_with_counter_and_ranks(
std::vector<MsgWithCounterAndRanks> msgs_with_counter_and_ranks;
// Put messages of the gather rank in msgs_with_counter_and_ranks
+ msgs_with_counter_and_ranks.reserve(my_msg_map.size());
for (const auto& el : my_msg_map)
{
msgs_with_counter_and_ranks.emplace_back(