Skip to content

Commit

Permalink
config: Don't create differently-typed copies of input in loops
Browse files Browse the repository at this point in the history
This is prompted by 1f8101e. This
approach should still be correct while hopefully not bothering any
compilers *and* avoiding unnecessary copies or conversions until the
input actually needs to be converted to a different type (in this case
std::string_view, which is cheaper than std::string).
  • Loading branch information
irydacea committed May 13, 2021
1 parent 24a5ea9 commit 6794f23
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,15 @@ class config
void merge_attributes(const config &);
template<typename... T>
void remove_attributes(T... keys) {
for(const std::string key : {keys...}) {
for(const auto& key : {keys...}) {
remove_attribute(key);
}
}

template<typename... T>
void copy_attributes(const config& from, T... keys)
{
for(const std::string key : {keys...}) {
for(const auto& key : {keys...}) {
auto* attr = from.get(key);
if(attr) {
(*this)[key] = *attr;
Expand Down

0 comments on commit 6794f23

Please sign in to comment.