Fix O(n²) string construction in codegen-js, lexer, parser, elb

Replace accumulate-by-concatenation loops with native_list_append + str_join.
Eliminates quadratic memory growth when processing large source files.
This is the v2 compiler state — what produced /tmp/elc-v2.
This commit is contained in:
Will Anderson
2026-05-02 22:35:49 -05:00
parent 2a211992d4
commit 3d71db4958
4 changed files with 84 additions and 75 deletions
+3 -1
View File
@@ -234,7 +234,9 @@ fn compile_module(src_path: String, out_dir: String, elc_bin: String, dry_run: B
return true
}
let cmd: String = elc_bin + " --emit-header " + src_path + " " + c_out
// elc streams C to stdout (collect mode not yet implemented); use
// shell redirection so the output lands in the file, not the terminal.
let cmd: String = elc_bin + " --emit-header " + src_path + " > " + c_out + " 2>&1"
println(" compile " + src_path)
if dry_run { return true }