]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/Formatter: use range-based `for`
authorMax Kellermann <max.kellermann@ionos.com>
Fri, 4 Oct 2024 13:15:53 +0000 (15:15 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Mon, 9 Dec 2024 11:49:22 +0000 (12:49 +0100)
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/common/Formatter.cc

index 3bc51618d4a3618d221a349ee41da0d3c5461aab..ec358c2f244c68e3d8c45fe9da01edfb8277bebb 100644 (file)
@@ -586,9 +586,7 @@ void XMLFormatter::get_attrs_str(const FormatterAttrs *attrs, std::string& attrs
 {
   CachedStackStringStream css;
 
-  for (std::list<std::pair<std::string, std::string> >::const_iterator iter = attrs->attrs.begin();
-       iter != attrs->attrs.end(); ++iter) {
-    std::pair<std::string, std::string> 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<std::pair<std::string, std::string> >::const_iterator iter = attrs->attrs.begin();
-       iter != attrs->attrs.end(); ++iter) {
-    std::pair<std::string, std::string> p = *iter;
+  for (const auto &p : attrs->attrs) {
     *css << " " << p.first << "=" << "\"" << p.second << "\"";
   }