Skip to content

Commit

Permalink
Use fmt_buffer join str to simplify str join operation
Browse files Browse the repository at this point in the history
Signed-off-by: yibin <huyibin@pingcap.com>
  • Loading branch information
yibin87 committed Apr 21, 2022
1 parent 084e3dc commit 567f395
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions dbms/src/Debug/dbgFuncCoprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,23 +378,13 @@ void dbgFuncTiDBQueryFromNaturalDag(Context & context, const ASTs & args, DBGInv
if (!failed_req_msg_vec.empty())
{
output("Invalid");
FmtBuffer msg_buffer;
bool first = true;
for (auto & it : failed_req_msg_vec)
{
String msg = fmt::format("request {} failed, msg: {}", it.first, it.second);
if (first)
{
msg_buffer.append(msg);
first = false;
}
else
{
msg_buffer.append("\n");
msg_buffer.append(msg);
}
}
throw Exception(msg_buffer.toString(), ErrorCodes::LOGICAL_ERROR);
FmtBuffer fmt_buf;
fmt_buf.joinStr(
failed_req_msg_vec.begin(),
failed_req_msg_vec.end(),
[](const auto & pair, FmtBuffer & fb) { fb.fmtAppend("request {} failed, msg: {}", pair.first, pair.second); },
"\n");
throw Exception(fmt_buf.toString(), ErrorCodes::LOGICAL_ERROR);
}
}

Expand Down

0 comments on commit 567f395

Please sign in to comment.