瀏覽代碼

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.

(cherry picked from commit ef914dac31f23fb8bd4c5e498a68ebd4ca4e1430)
lawnjelly 2 年之前
父節點
當前提交
2e8e7b8b79
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      modules/gdscript/gdscript_parser.cpp

+ 2 - 2
modules/gdscript/gdscript_parser.cpp

@@ -8592,8 +8592,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<BlockNode *>::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) {