diff options
| author | gingerBill <bill@gingerbill.org> | 2020-11-16 15:18:25 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-11-16 15:18:25 +0000 |
| commit | ca4b0527e80bda39aa677f013415eff0c62f433d (patch) | |
| tree | 94220a881bd41166485a733b1f3735cebb967619 /src/checker.cpp | |
| parent | adf6c85fd3130ed22e98f2cf5b7f88079f056488 (diff) | |
Minimize memory usage for AST nodes by using Slice<T> rather than Array<T> when the parameter doesn't need to grow
Diffstat (limited to 'src/checker.cpp')
| -rw-r--r-- | src/checker.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index 380872f24..f02b927c3 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -2854,7 +2854,7 @@ void check_decl_attributes(CheckerContext *c, Array<Ast *> const &attributes, De } -isize get_total_value_count(Array<Ast *> const &values) { +isize get_total_value_count(Slice<Ast *> const &values) { isize count = 0; for_array(i, values) { Type *t = type_of_expr(values[i]); @@ -3068,7 +3068,7 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) { } else { entity_visibility_kind = kind; } - array_unordered_remove(elems, j); + slice_unordered_remove(elems, j); j -= 1; } } @@ -3252,7 +3252,7 @@ void check_add_foreign_block_decl(CheckerContext *ctx, Ast *decl) { } // NOTE(bill): If file_scopes == nullptr, this will act like a local scope -void check_collect_entities(CheckerContext *c, Array<Ast *> const &nodes) { +void check_collect_entities(CheckerContext *c, Slice<Ast *> const &nodes) { for_array(decl_index, nodes) { Ast *decl = nodes[decl_index]; if (!is_ast_decl(decl) && !is_ast_when_stmt(decl)) { @@ -3783,7 +3783,7 @@ void check_add_foreign_import_decl(CheckerContext *ctx, Ast *decl) { } } -bool collect_checked_packages_from_decl_list(Checker *c, Array<Ast *> const &decls) { +bool collect_checked_packages_from_decl_list(Checker *c, Slice<Ast *> const &decls) { bool new_files = false; for_array(i, decls) { Ast *decl = decls[i]; @@ -3805,7 +3805,7 @@ bool collect_checked_packages_from_decl_list(Checker *c, Array<Ast *> const &dec } // Returns true if a new package is present -bool collect_file_decls(CheckerContext *ctx, Array<Ast *> const &decls); +bool collect_file_decls(CheckerContext *ctx, Slice<Ast *> const &decls); bool collect_file_decls_from_when_stmt(CheckerContext *ctx, AstWhenStmt *ws); bool collect_when_stmt_from_file(CheckerContext *ctx, AstWhenStmt *ws) { @@ -3880,7 +3880,7 @@ bool collect_file_decls_from_when_stmt(CheckerContext *ctx, AstWhenStmt *ws) { return false; } -bool collect_file_decls(CheckerContext *ctx, Array<Ast *> const &decls) { +bool collect_file_decls(CheckerContext *ctx, Slice<Ast *> const &decls) { GB_ASSERT(ctx->scope->flags&ScopeFlag_File); if (collect_checked_packages_from_decl_list(ctx->checker, decls)) { |