@@ -85,7 +85,7 @@ FormatterAttrs::FormatterAttrs(const char *attr, ...)
8585 if (!val)
8686 break ;
8787
88- attrs.push_back ( make_pair ( std::string (s), std::string ( val)) );
88+ attrs.emplace_back (s, val);
8989 s = va_arg (ap, char *);
9090 } while (s);
9191 va_end (ap);
@@ -607,13 +607,11 @@ void XMLFormatter::write_bin_data(const char* buff, int buf_len)
607607 m_ss.seekg (buf_len);
608608}
609609
610- void XMLFormatter::get_attrs_str (const FormatterAttrs *attrs, std::string& attrs_str)
610+ void XMLFormatter::get_attrs_str (const FormatterAttrs *attrs, std::string& attrs_str) const
611611{
612612 CachedStackStringStream css;
613613
614- for (std::list<std::pair<std::string, std::string> >::const_iterator iter = attrs->attrs .begin ();
615- iter != attrs->attrs .end (); ++iter) {
616- std::pair<std::string, std::string> p = *iter;
614+ for (const auto &p : attrs->attrs ) {
617615 *css << " " << p.first << " =" << " \" " << p.second << " \" " ;
618616 }
619617
@@ -874,9 +872,9 @@ size_t TableFormatter::m_vec_index(std::string_view name)
874872std::string TableFormatter::get_section_name (std::string_view name)
875873{
876874 std::string t_name{name};
877- for (size_t i = 0 ; i < m_section. size (); i++ ) {
875+ for (const auto &i : m_section) {
878876 t_name.insert (0 , " :" );
879- t_name.insert (0 , m_section[i] );
877+ t_name.insert (0 , i );
880878 }
881879 if (m_section_open) {
882880 std::stringstream lss;
@@ -996,13 +994,11 @@ void TableFormatter::write_raw_data(const char *data) {
996994 // not supported
997995}
998996
999- void TableFormatter::get_attrs_str (const FormatterAttrs *attrs, std::string& attrs_str)
997+ void TableFormatter::get_attrs_str (const FormatterAttrs *attrs, std::string& attrs_str) const
1000998{
1001999 CachedStackStringStream css;
10021000
1003- for (std::list<std::pair<std::string, std::string> >::const_iterator iter = attrs->attrs .begin ();
1004- iter != attrs->attrs .end (); ++iter) {
1005- std::pair<std::string, std::string> p = *iter;
1001+ for (const auto &p : attrs->attrs ) {
10061002 *css << " " << p.first << " =" << " \" " << p.second << " \" " ;
10071003 }
10081004
0 commit comments