Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Speedup running very big GDScript files #53507

Merged
merged 1 commit into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,8 +1188,8 @@ static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const S
}
}

for (const List<GDScriptParser::Node *>::Element *E = blk->statements.front(); E; E = E->next()) {
const GDScriptParser::Node *expr = E->get();
for (int z = 0; z < blk->statements.size(); z++) {
Copy link
Contributor

@AaronRecord AaronRecord Oct 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this use a range iterator? #50284
Or is that worse for performance in some way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Range iterators are implemented only in master branch, but I use 3.x branch in this commit

const GDScriptParser::Node *expr = blk->statements[z];
if (expr->line > p_context.line || expr->type != GDScriptParser::Node::TYPE_OPERATOR) {
continue;
}
Expand Down
8 changes: 4 additions & 4 deletions modules/gdscript/gdscript_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2793,8 +2793,8 @@ void GDScriptParser::_transform_match_statment(MatchNode *p_match_statement) {
op->arguments.push_back(local_var->assign);
local_var->assign_op = op;

branch->body->statements.push_front(op);
branch->body->statements.push_front(local_var);
branch->body->statements.insert(0, op);
branch->body->statements.insert(0, local_var);
}

compiled_branch.body = branch->body;
Expand Down Expand Up @@ -8252,8 +8252,8 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
Node *last_var_assign = nullptr;

// Check each statement
for (List<Node *>::Element *E = p_block->statements.front(); E; E = E->next()) {
Node *statement = E->get();
for (int z = 0; z < p_block->statements.size(); z++) {
Node *statement = p_block->statements[z];
switch (statement->type) {
case Node::TYPE_NEWLINE:
case Node::TYPE_BREAKPOINT: {
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class GDScriptParser {
struct BlockNode : public Node {
ClassNode *parent_class;
BlockNode *parent_block;
List<Node *> statements;
Vector<Node *> statements;
Map<StringName, LocalVarNode *> variables;
bool has_return = false;
bool can_break = false;
Expand Down