Skip to content

Commit 673d020

Browse files
committed
common/Formatter: use range-based for
Signed-off-by: Max Kellermann <[email protected]>
1 parent e8e3b93 commit 673d020

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/common/Formatter.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,7 @@ void XMLFormatter::get_attrs_str(const FormatterAttrs *attrs, std::string& attrs
586586
{
587587
CachedStackStringStream css;
588588

589-
for (std::list<std::pair<std::string, std::string> >::const_iterator iter = attrs->attrs.begin();
590-
iter != attrs->attrs.end(); ++iter) {
591-
std::pair<std::string, std::string> p = *iter;
589+
for (const auto &p : attrs->attrs) {
592590
*css << " " << p.first << "=" << "\"" << p.second << "\"";
593591
}
594592

@@ -849,9 +847,9 @@ size_t TableFormatter::m_vec_index(std::string_view name)
849847
std::string TableFormatter::get_section_name(std::string_view name)
850848
{
851849
std::string t_name{name};
852-
for (size_t i = 0; i < m_section.size(); i++) {
850+
for (const auto &i : m_section) {
853851
t_name.insert(0, ":");
854-
t_name.insert(0, m_section[i]);
852+
t_name.insert(0, i);
855853
}
856854
if (m_section_open) {
857855
std::stringstream lss;
@@ -963,9 +961,7 @@ void TableFormatter::get_attrs_str(const FormatterAttrs *attrs, std::string& att
963961
{
964962
CachedStackStringStream css;
965963

966-
for (std::list<std::pair<std::string, std::string> >::const_iterator iter = attrs->attrs.begin();
967-
iter != attrs->attrs.end(); ++iter) {
968-
std::pair<std::string, std::string> p = *iter;
964+
for (const auto &p : attrs->attrs) {
969965
*css << " " << p.first << "=" << "\"" << p.second << "\"";
970966
}
971967

0 commit comments

Comments
 (0)