Speed up parser by allocating more space for its statements initially.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
0d59a1d029
commit
74d23530a1
|
@ -8,16 +8,19 @@
|
|||
|
||||
namespace Porygon::Parser {
|
||||
ParsedScriptStatement *Parser::Parse() {
|
||||
vector<const ParsedStatement *> statements;
|
||||
vector<const ParsedStatement *> statements(this->_tokens.size());
|
||||
size_t current = 0;
|
||||
while (this->_position < this->_tokens.size()) {
|
||||
auto next = this->Next();
|
||||
if (next->GetKind() == TokenKind::EndOfFile) {
|
||||
break;
|
||||
}
|
||||
statements.push_back(this->ParseStatement(next));
|
||||
statements[current] = this -> ParseStatement(next);
|
||||
current++;
|
||||
}
|
||||
statements.resize(current);
|
||||
auto end = 0;
|
||||
if (statements.size() > 0){
|
||||
if (current > 0){
|
||||
end = statements.back()->GetEndPosition();
|
||||
}
|
||||
return new ParsedScriptStatement(statements, 0, end);
|
||||
|
|
Loading…
Reference in New Issue