compiler: a string slice is a fresh temporary too

s[a .. b] is always a copy, so it is freed once a +, a comparison or print has read it. Reseeded.
string_temps.ludic adds a slice compared and a slice concatenated each round (960 KB over 20,000
before, 0 after) and a kept slice read after its +.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 12:25:02 +03:00
parent 174a32c285
commit 328dee77c8
5 changed files with 940 additions and 861 deletions

View file

@ -7,3 +7,5 @@ of those as soon as the next `+`, the comparison or `print` has read it, and `st
the start of what it allocated so its text can be freed at all. A string held anywhere - a
variable, an argument, a function's result - is left alone. A loop of 20,000 template builds grew
2.9 MB and now grows 0 (`examples/lang/string_temps.ludic`).
A slice of a string (`s[a .. b]`, always a copy) counts too: `path[0 .. n - 4] + ".dds"` and
`path[n - 4 .. n] == ".png"` no longer leave the slice behind.