From d6ea2e4c2f65ec3e8cf04f0e8c003d62131aee34 Mon Sep 17 00:00:00 2001 From: Niels Bross Date: Thu, 11 Sep 2025 12:27:44 +0200 Subject: [PATCH] Memory optimization for the general case by reserving significantly fewer tokens in lexer. It was reserving 1 million always! --- Lexing.jai | 2 +- test/codegen_all.suite | 1 + test/compile_all.suite | 1 + test/lex_all.suite | 1 + test/parse_all.suite | 1 + test/semant_all.suite | 2 +- 6 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Lexing.jai b/Lexing.jai index ad4f9e4..9afd815 100644 --- a/Lexing.jai +++ b/Lexing.jai @@ -577,7 +577,7 @@ lex :: (ctx : *Compiler_Context, allocator := temp) { lexer : Lexer; lexer.ctx = ctx; - array_reserve(*lexer.ctx.tokens, 1024 * 1024); + array_reserve(*lexer.ctx.tokens, 1024); init_lexer_from_string(*lexer, ctx.file.source); lexer.path = ctx.file.path; diff --git a/test/codegen_all.suite b/test/codegen_all.suite index 3108a84..4c8f5e4 100644 --- a/test/codegen_all.suite +++ b/test/codegen_all.suite @@ -1,5 +1,6 @@ test/assign_arithmetic_expression.ink codegen test/basic_property_and_return_value.ink codegen +test/builtin_types.ink codegen test/complicated_computation.ink codegen test/constant_buffer.ink codegen test/empty_struct.ink codegen diff --git a/test/compile_all.suite b/test/compile_all.suite index 7f12ef6..2bb5618 100644 --- a/test/compile_all.suite +++ b/test/compile_all.suite @@ -1,5 +1,6 @@ test/assign_arithmetic_expression.ink compile test/basic_property_and_return_value.ink compile +test/builtin_types.ink compile test/complicated_computation.ink compile test/empty_struct.ink compile test/empty_vertex_main.ink compile diff --git a/test/lex_all.suite b/test/lex_all.suite index 28e58de..9655939 100644 --- a/test/lex_all.suite +++ b/test/lex_all.suite @@ -1,5 +1,6 @@ test/assign_arithmetic_expression.ink lex test/basic_property_and_return_value.ink lex +test/builtin_types.ink lex test/complicated_computation.ink lex test/constant_buffer.ink lex test/else_if_after_else.ink lex diff --git a/test/parse_all.suite b/test/parse_all.suite index 504285a..0fa32a8 100644 --- a/test/parse_all.suite +++ b/test/parse_all.suite @@ -1,5 +1,6 @@ test/assign_arithmetic_expression.ink parse test/basic_property_and_return_value.ink parse +test/builtin_types.ink parse test/complicated_computation.ink parse test/constant_buffer.ink parse test/else_if_after_else.ink parse diff --git a/test/semant_all.suite b/test/semant_all.suite index 76df837..1bc6016 100644 --- a/test/semant_all.suite +++ b/test/semant_all.suite @@ -1,6 +1,7 @@ test/assign_arithmetic_expression.ink semant test/basic_property_and_return_value.ink semant +test/builtin_types.ink semant test/complicated_computation.ink semant test/constant_buffer.ink semant test/empty_struct.ink semant @@ -8,7 +9,6 @@ test/empty_vertex_main.ink semant test/empty_vertex_main_with_position_parameter.ink semant test/field_assignment.ink semant test/for_i_loop.ink semant -test/for_i_one_liner.ink semant test/function_call.ink semant test/function_call_out_of_order_declaration.ink semant test/function_call_return.ink semant