Crinja::Template
=== 8. Presized page buffer ==========================================
Template#render(bindings) builds its result with a default String.build,
which starts at 64 bytes and doubles. A 400 KB page therefore reallocates
about thirteen times and memcpys roughly twice its own size before it is
finished — per page, on every page.
Consecutive renders of the SAME template produce similarly sized output (a
listing page is a listing page), so the previous render's size is a good
capacity hint. It is only a hint: too small and String::Builder grows
exactly as it does today, too large and the final String.build trims the
excess. No byte of output depends on it.
@render_size_hint is an aligned Int32 shared between render workers, so a
concurrent write cannot tear — the worst case is a worker reading a size
from a different page, which is the same class of estimate the value is.
Instance methods
Renders this template as a String using bindings as local variables scope.