From 9dfa5395631bab1cbb0556536dbd4151777c3f4f Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Sun, 2 Apr 2023 12:12:21 +0200 Subject: [PATCH] Using ForArrayRemovable --- base_data_structures.cpp | 1 + core_polymorph.cpp | 7 +++---- core_typechecking.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/base_data_structures.cpp b/base_data_structures.cpp index 9780344..a77c825 100644 --- a/base_data_structures.cpp +++ b/base_data_structures.cpp @@ -1,3 +1,4 @@ +#include "core/defer.hpp" #define ARRAY_ALLOCATOR_TYPE Allocator #define ARRAY_ASSERT assert #define ARRAY_ALLOCATE(allocator, size) allocate_size(allocator, size) diff --git a/core_polymorph.cpp b/core_polymorph.cpp index b07804f..40621ce 100644 --- a/core_polymorph.cpp +++ b/core_polymorph.cpp @@ -354,11 +354,10 @@ Ast_Decl *get_or_instantiate_polymorph_lambda(Token *pos, Ast_Decl *poly, Array< if (!result) { result = (Ast_Decl *)ast_copy(poly, poly->parent_scope, &poly->polymorph_parameters, ¶ms); - for (int i = 0; i < result->lambda->args.len; i += 1) { - auto &it = result->lambda->args[i]; + ForArrayRemovable(result->lambda->args) { + ForArrayRemovablePrepare(result->lambda->args); if (it->flags & AST_IDENT_POLYMORPH) { - result->lambda->args.ordered_remove(it); - i -= 1; // @verify: Need to pay attention if this is correct + ForArrayRemovableDeclare(); } } diff --git a/core_typechecking.cpp b/core_typechecking.cpp index ebb1a62..e2493ad 100644 --- a/core_typechecking.cpp +++ b/core_typechecking.cpp @@ -1696,12 +1696,12 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_and_const_str // Find the polymorph if (lambda->flags & AST_POLYMORPH) { Array replacements = {scratch.arena}; - for (int i = 0; i < matches.len; i += 1) { - Match &it = matches[i]; + ForArrayRemovable(matches) { + ForArrayRemovablePrepare(matches); + if (it.lambda_arg->flags & AST_POLYMORPH) { replacements.add(it.call_arg); - matches.ordered_remove(it); // @verify: Need to pay attention if this is correct - i -= 1; + ForArrayRemovableDeclare(); } }