mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 05:22:17 +00:00
Move Tokens::operator and optimize the common path
This commit is contained in:
parent
96a1cb4a79
commit
7b96a7b798
@ -4,6 +4,25 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
const Token & Tokens::operator[](size_t index)
|
||||
{
|
||||
if (likely(index < data.size()))
|
||||
return data[index];
|
||||
|
||||
while (data.empty() || !data.back().isEnd())
|
||||
{
|
||||
Token token = lexer.nextToken();
|
||||
|
||||
if (token.isSignificant())
|
||||
{
|
||||
data.emplace_back(std::move(token));
|
||||
if (index < data.size())
|
||||
return data[index];
|
||||
}
|
||||
}
|
||||
return data.back();
|
||||
}
|
||||
|
||||
UnmatchedParentheses checkUnmatchedParentheses(TokenIterator begin)
|
||||
{
|
||||
/// We have just two kind of parentheses: () and [].
|
||||
|
@ -25,22 +25,7 @@ private:
|
||||
public:
|
||||
Tokens(const char * begin, const char * end, size_t max_query_size = 0) : lexer(begin, end, max_query_size) {}
|
||||
|
||||
const Token & operator[] (size_t index)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (index < data.size())
|
||||
return data[index];
|
||||
|
||||
if (!data.empty() && data.back().isEnd())
|
||||
return data.back();
|
||||
|
||||
Token token = lexer.nextToken();
|
||||
|
||||
if (token.isSignificant())
|
||||
data.emplace_back(token);
|
||||
}
|
||||
}
|
||||
const Token & operator[](size_t index);
|
||||
|
||||
const Token & max()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user