use operator+=(char)

This commit is contained in:
pavel.pimenov 2017-06-01 11:17:01 +03:00 committed by Arvid Norberg
parent 5344761da4
commit 781a35a210
5 changed files with 23 additions and 23 deletions

View File

@ -1012,23 +1012,23 @@ done:
if (!one_liner) ret += indent_str + 1; if (!one_liner) ret += indent_str + 1;
for (int i = 0; i < e.list_size(); ++i) for (int i = 0; i < e.list_size(); ++i)
{ {
if (i == 0 && one_liner) ret += " "; if (i == 0 && one_liner) ret += ' ';
ret += print_entry(e.list_at(i), single_line, indent + 2); ret += print_entry(e.list_at(i), single_line, indent + 2);
if (i < e.list_size() - 1) ret += (one_liner ? ", " : indent_str); if (i < e.list_size() - 1) ret += (one_liner ? ", " : indent_str);
else ret += (one_liner ? " " : indent_str + 1); else ret += (one_liner ? " " : indent_str + 1);
} }
ret += "]"; ret += ']';
return ret; return ret;
} }
case bdecode_node::dict_t: case bdecode_node::dict_t:
{ {
ret += "{"; ret += '{';
bool one_liner = line_longer_than(e, 200) != -1 || single_line; bool one_liner = line_longer_than(e, 200) != -1 || single_line;
if (!one_liner) ret += indent_str + 1; if (!one_liner) ret += indent_str + 1;
for (int i = 0; i < e.dict_size(); ++i) for (int i = 0; i < e.dict_size(); ++i)
{ {
if (i == 0 && one_liner) ret += " "; if (i == 0 && one_liner) ret += ' ';
std::pair<string_view, bdecode_node> ent = e.dict_at(i); std::pair<string_view, bdecode_node> ent = e.dict_at(i);
print_string(ret, ent.first, true); print_string(ret, ent.first, true);
ret += ": "; ret += ": ";
@ -1036,7 +1036,7 @@ done:
if (i < e.dict_size() - 1) ret += (one_liner ? ", " : indent_str); if (i < e.dict_size() - 1) ret += (one_liner ? ", " : indent_str);
else ret += (one_liner ? " " : indent_str + 1); else ret += (one_liner ? " " : indent_str + 1);
} }
ret += "}"; ret += '}';
return ret; return ret;
} }
} }

View File

@ -644,12 +644,12 @@ namespace {
void entry::to_string_impl(std::string& out, int indent) const void entry::to_string_impl(std::string& out, int indent) const
{ {
TORRENT_ASSERT(indent >= 0); TORRENT_ASSERT(indent >= 0);
for (int i = 0; i < indent; ++i) out += " "; for (int i = 0; i < indent; ++i) out += ' ';
switch (type()) switch (type())
{ {
case int_t: case int_t:
out += libtorrent::to_string(integer()).data(); out += libtorrent::to_string(integer()).data();
out += "\n"; out += '\n';
break; break;
case string_t: case string_t:
{ {
@ -665,12 +665,12 @@ namespace {
if (binary_string) if (binary_string)
{ {
out += aux::to_hex(string()); out += aux::to_hex(string());
out += "\n"; out += '\n';
} }
else else
{ {
out += string(); out += string();
out += "\n"; out += '\n';
} }
} break; } break;
case list_t: case list_t:
@ -695,16 +695,16 @@ namespace {
break; break;
} }
} }
for (int j = 0; j < indent + 1; ++j) out += " "; for (int j = 0; j < indent + 1; ++j) out += ' ';
out += "["; out += '[';
if (binary_string) out += aux::to_hex(i->first); if (binary_string) out += aux::to_hex(i->first);
else out += i->first; else out += i->first;
out += "]"; out += ']';
if (i->second.type() != entry::string_t if (i->second.type() != entry::string_t
&& i->second.type() != entry::int_t) && i->second.type() != entry::int_t)
out += "\n"; out += '\n';
else out += " "; else out += ' ';
i->second.to_string_impl(out, indent + 2); i->second.to_string_impl(out, indent + 2);
} }
} break; } break;

View File

@ -288,7 +288,7 @@ namespace libtorrent {
{ {
std::string ret; std::string ret;
ret += to_string(ev).data(); ret += to_string(ev).data();
ret += " "; ret += ' ';
switch (ev) switch (ev)
{ {
case errors::cont: ret += "Continue"; break; case errors::cont: ret += "Continue"; break;

View File

@ -634,18 +634,18 @@ namespace {
if (i < e.list_size() - 1) ret += (one_liner?", ":indent_str); if (i < e.list_size() - 1) ret += (one_liner?", ":indent_str);
else ret += (one_liner?" ":indent_str+1); else ret += (one_liner?" ":indent_str+1);
} }
ret += "]"; ret += ']';
return ret; return ret;
} }
case lazy_entry::dict_t: case lazy_entry::dict_t:
{ {
ret += "{"; ret += '{';
bool one_liner = line_longer_than(e, 200) != -1 || single_line; bool one_liner = line_longer_than(e, 200) != -1 || single_line;
if (!one_liner) ret += indent_str+1; if (!one_liner) ret += indent_str+1;
for (int i = 0; i < e.dict_size(); ++i) for (int i = 0; i < e.dict_size(); ++i)
{ {
if (i == 0 && one_liner) ret += " "; if (i == 0 && one_liner) ret += ' ';
std::pair<std::string, lazy_entry const*> ent = e.dict_at(i); std::pair<std::string, lazy_entry const*> ent = e.dict_at(i);
print_string(ret, ent.first.c_str(), int(ent.first.size()), true); print_string(ret, ent.first.c_str(), int(ent.first.size()), true);
ret += ": "; ret += ": ";

View File

@ -166,7 +166,7 @@ namespace libtorrent {
std::string ret; std::string ret;
for (auto const& i : in) for (auto const& i : in)
{ {
if (!ret.empty()) ret += ","; if (!ret.empty()) ret += ',';
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
error_code ec; error_code ec;
@ -174,18 +174,18 @@ namespace libtorrent {
if (!ec) if (!ec)
{ {
// IPv6 addresses must be wrapped in square brackets // IPv6 addresses must be wrapped in square brackets
ret += "["; ret += '[';
ret += i.device; ret += i.device;
ret += "]"; ret += ']';
} }
else else
#endif #endif
{ {
ret += i.device; ret += i.device;
} }
ret += ":"; ret += ':';
ret += to_string(i.port).data(); ret += to_string(i.port).data();
if (i.ssl) ret += "s"; if (i.ssl) ret += 's';
} }
return ret; return ret;