Slightly better code #3940

This commit is contained in:
Alexey Milovidov 2018-12-28 19:45:45 +03:00
parent e21f414a34
commit 06095340c7

View File

@ -28,29 +28,30 @@ public:
if (!enabled_)
return;
String full_comment;
Lexer lexer(query.data(), query.data() + query.size());
for (Token token = lexer.nextToken(); !token.isEnd(); token = lexer.nextToken())
{
if (token.type == TokenType::Comment)
full_comment += String(token.begin, token.begin + token.size()) + ' ';
}
if (!full_comment.empty())
{
size_t pos_start = full_comment.find('{', 0);
String comment(token.begin, token.begin + token.size());
if (!comment.empty())
{
size_t pos_start = comment.find('{', 0);
if (pos_start != String::npos)
{
size_t pos_end = full_comment.find('}', pos_start);
size_t pos_end = comment.find('}', pos_start);
if (pos_end != String::npos)
{
String hint(full_comment.begin() + pos_start + 1, full_comment.begin() + pos_end);
String hint(comment.begin() + pos_start + 1, comment.begin() + pos_end);
parse(hint);
}
}
}
}
}
}
/// @returns true if it's possible to continue without reconnect
bool checkActual(int & actual_server_error, int & actual_client_error,