From: Max Kellermann Date: Fri, 4 Oct 2024 13:15:53 +0000 (+0200) Subject: common/Formatter: use range-based `for` X-Git-Tag: v20.0.0~170^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=673d0200b204cef345c8db43f7f5b363e810cacc;p=ceph.git common/Formatter: use range-based `for` Signed-off-by: Max Kellermann --- diff --git a/src/common/Formatter.cc b/src/common/Formatter.cc index 3bc51618d4a..ec358c2f244 100644 --- a/src/common/Formatter.cc +++ b/src/common/Formatter.cc @@ -586,9 +586,7 @@ void XMLFormatter::get_attrs_str(const FormatterAttrs *attrs, std::string& attrs { CachedStackStringStream css; - for (std::list >::const_iterator iter = attrs->attrs.begin(); - iter != attrs->attrs.end(); ++iter) { - std::pair p = *iter; + for (const auto &p : attrs->attrs) { *css << " " << p.first << "=" << "\"" << p.second << "\""; } @@ -849,9 +847,9 @@ size_t TableFormatter::m_vec_index(std::string_view name) std::string TableFormatter::get_section_name(std::string_view name) { std::string t_name{name}; - for (size_t i = 0; i < m_section.size(); i++) { + for (const auto &i : m_section) { t_name.insert(0, ":"); - t_name.insert(0, m_section[i]); + t_name.insert(0, i); } if (m_section_open) { std::stringstream lss; @@ -963,9 +961,7 @@ void TableFormatter::get_attrs_str(const FormatterAttrs *attrs, std::string& att { CachedStackStringStream css; - for (std::list >::const_iterator iter = attrs->attrs.begin(); - iter != attrs->attrs.end(); ++iter) { - std::pair p = *iter; + for (const auto &p : attrs->attrs) { *css << " " << p.first << "=" << "\"" << p.second << "\""; }