From 3d1abe86fb80254082dd277a92d4baa6b4af287c Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 18 Mar 2023 09:29:08 +0100 Subject: [PATCH] Ported: GDScriptParser - don't use index operator on linked list Index operators are super slow with linked lists. This came up in profiling the parsing, iterating sequentially using iterator is much faster. - lawnjelly https://github.com/godotengine/godot/commit/ef914dac31f23fb8bd4c5e498a68ebd4ca4e1430 --- modules/cscript/cscript_parser.cpp | 4 ++-- modules/gdscript/gdscript_parser.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/cscript/cscript_parser.cpp b/modules/cscript/cscript_parser.cpp index 143a53f2f..2b5046cfb 100644 --- a/modules/cscript/cscript_parser.cpp +++ b/modules/cscript/cscript_parser.cpp @@ -8405,8 +8405,8 @@ void CScriptParser::_check_block_types(BlockNode *p_block) { } // Parse sub blocks - for (int i = 0; i < p_block->sub_blocks.size(); i++) { - current_block = p_block->sub_blocks[i]; + for (const List::Element *E = p_block->sub_blocks.front(); E; E = E->next()) { + current_block = E->get(); _check_block_types(current_block); current_block = p_block; if (error_set) { diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 909310791..e6cc88401 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -8520,8 +8520,8 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) { } // Parse sub blocks - for (int i = 0; i < p_block->sub_blocks.size(); i++) { - current_block = p_block->sub_blocks[i]; + for (const List::Element *E = p_block->sub_blocks.front(); E; E = E->next()) { + current_block = E->get(); _check_block_types(current_block); current_block = p_block; if (error_set) {