Speed up parser by allocating more space for its statements initially.
continuous-integration/drone/push Build is passing

This commit is contained in:
Deukhoofd committed 2019-09-21 09:52:22 +02:00
1 parent 0d59a1d029
commit 74d23530a1
1 file changed
+6 -3
+6 -3
View File
@@ -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);