From 66d19b5af7ba7c1dff5570bfed69946c8f06971d Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Tue, 26 Sep 2023 12:15:07 -0600 Subject: [PATCH] Using emplace when OK --- barry.hpp | 4 ++-- defm.hpp | 6 +++--- include/barry/barrayvector-meat.hpp | 2 +- include/barry/counters-meat.hpp | 2 +- include/barry/model-meat.hpp | 2 +- include/barry/models/defm/counters.hpp | 2 +- include/barry/models/defm/defm-meat.hpp | 4 ++-- include/barry/models/geese/flock-meat.hpp | 2 +- include/barry/models/geese/geese-meat.hpp | 6 +++--- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/barry.hpp b/barry.hpp index 459cf1950..fc9e79e05 100644 --- a/barry.hpp +++ b/barry.hpp @@ -5378,7 +5378,7 @@ COUNTERS_TEMPLATE(void, add_counter)( ) { - data.push_back(Counter( + data.emplace_back(Counter( count_fun_, init_fun_, hasher_fun_, @@ -7904,7 +7904,7 @@ MODEL_TEMPLATE(size_t, add_array)( { auto tmpcounts = counter_fun.count_all(); - stats_target.push_back( + stats_target.emplace_back( transform_model_fun(&tmpcounts[0u], tmpcounts.size()) ); diff --git a/defm.hpp b/defm.hpp index 68f7df02b..43262becb 100644 --- a/defm.hpp +++ b/defm.hpp @@ -956,7 +956,7 @@ inline void counter_transition( #ifdef BARRY_WITH_LATEX name += ") -> ("; #else - name += "} \u21E8 {"; + name += std::string("}") + u8"\u21E8" + std::string("{"); #endif else #ifdef BARRY_WITH_LATEX @@ -1529,10 +1529,10 @@ inline DEFM::DEFM( // Creating the names for (auto i = 0u; i < Y_ncol; ++i) - Y_names.push_back(std::string("y") + std::to_string(i)); + Y_names.emplace_back(std::string("y") + std::to_string(i)); for (auto i = 0u; i < X_ncol; ++i) - X_names.push_back(std::string("X") + std::to_string(i)); + X_names.emplace_back(std::string("X") + std::to_string(i)); return; diff --git a/include/barry/barrayvector-meat.hpp b/include/barry/barrayvector-meat.hpp index 0128e3cfa..29528bbe9 100644 --- a/include/barry/barrayvector-meat.hpp +++ b/include/barry/barrayvector-meat.hpp @@ -16,7 +16,7 @@ inline void BArrayVector::init_vec() { } else { for (const auto& a : Array->el_ji[i]) - vec.push_back(std::make_pair>(a.first, *(a.second))); + vec.emplace_back(std::make_pair>(a.first, *(a.second))); } diff --git a/include/barry/counters-meat.hpp b/include/barry/counters-meat.hpp index 484aa10e7..6c5d13506 100644 --- a/include/barry/counters-meat.hpp +++ b/include/barry/counters-meat.hpp @@ -185,7 +185,7 @@ COUNTERS_TEMPLATE(void, add_counter)( ) { - data.push_back(Counter( + data.emplace_back(Counter( count_fun_, init_fun_, hasher_fun_, diff --git a/include/barry/model-meat.hpp b/include/barry/model-meat.hpp index 371f6d04c..623dad566 100644 --- a/include/barry/model-meat.hpp +++ b/include/barry/model-meat.hpp @@ -443,7 +443,7 @@ MODEL_TEMPLATE(size_t, add_array)( { auto tmpcounts = counter_fun.count_all(); - stats_target.push_back( + stats_target.emplace_back( transform_model_fun(&tmpcounts[0u], tmpcounts.size()) ); diff --git a/include/barry/models/defm/counters.hpp b/include/barry/models/defm/counters.hpp index 8d05d15a4..94cea3e5a 100644 --- a/include/barry/models/defm/counters.hpp +++ b/include/barry/models/defm/counters.hpp @@ -490,7 +490,7 @@ inline void counter_transition( #ifdef BARRY_WITH_LATEX name += ") -> ("; #else - name += "} \u21E8 {"; + name += std::string("}") + u8"\u21E8" + std::string("{"); #endif else #ifdef BARRY_WITH_LATEX diff --git a/include/barry/models/defm/defm-meat.hpp b/include/barry/models/defm/defm-meat.hpp index 0a5c7549a..36ab4cfa6 100644 --- a/include/barry/models/defm/defm-meat.hpp +++ b/include/barry/models/defm/defm-meat.hpp @@ -201,10 +201,10 @@ inline DEFM::DEFM( // Creating the names for (auto i = 0u; i < Y_ncol; ++i) - Y_names.push_back(std::string("y") + std::to_string(i)); + Y_names.emplace_back(std::string("y") + std::to_string(i)); for (auto i = 0u; i < X_ncol; ++i) - X_names.push_back(std::string("X") + std::to_string(i)); + X_names.emplace_back(std::string("X") + std::to_string(i)); return; diff --git a/include/barry/models/geese/flock-meat.hpp b/include/barry/models/geese/flock-meat.hpp index 0ad375777..8dd680aeb 100644 --- a/include/barry/models/geese/flock-meat.hpp +++ b/include/barry/models/geese/flock-meat.hpp @@ -30,7 +30,7 @@ inline size_t Flock::add_data( } // Generating the Geese object - dat.push_back(Geese(annotations, geneid, parent, duplication)); + dat.emplace_back(Geese(annotations, geneid, parent, duplication)); if (dat.size() == 1u) this->nfunctions = dat[0].nfuns(); diff --git a/include/barry/models/geese/geese-meat.hpp b/include/barry/models/geese/geese-meat.hpp index 8d5ba49a2..bccde6180 100644 --- a/include/barry/models/geese/geese-meat.hpp +++ b/include/barry/models/geese/geese-meat.hpp @@ -160,7 +160,7 @@ inline void Geese::init(size_t bar_width) { for (auto& iter : pset.data) { - states.push_back(std::vector< bool >(nfunctions, false)); + states.emplace_back(std::vector< bool >(nfunctions, false)); for (auto j = 0u; j < nfunctions; ++j) { @@ -539,7 +539,7 @@ inline std::vector< std::vector > Geese::observed_counts() if (n.second.is_leaf()) { - ans.push_back({}); + ans.emplace_back(std::vector({})); continue; } @@ -605,7 +605,7 @@ inline void Geese::print_observed_counts() for (auto& n : nodes) { if (n.second.is_leaf()) { - ans.push_back({}); + ans.emplace_back(std::vector< double >({})); continue; }