-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Dhilly promises to be a stack-first templating engine. However, over different iterations Dhilly has began allocating memory itself, leading to the engine itself making up to 5 allocations per template creation. This is unacceptable.
If we let the user provide a scratch buffer, Dhilly will intelligently be able to split it into different internal buffers or arenas. The first arena would simply copy all of the user-provided strings into a contiguous block. The second arena would be the "dynamic" arena and take up the rest? Assuming there isn't more data we need to store.
This will improve cpu cache locality and will allow us to make another big optimization in the string-array to string function by allowing us to intelligently copy strings by order in memory (left to right) instead of order in template, though more metadata will need to be added to make this functional.
Additionally, this would allow the user to provide an in-stack buffer, fulfilling Dhilly's goal to be usable on systems that don't support malloc.