Performance Optimization
Always benchmark with -prod and an optimizing C compiler (GCC/Clang). TCC is for fast dev builds only.
Preallocate arrays ([]T{cap: n}) and strings (strings.new_builder(n)).
Avoid unnecessary .clone(). Pass large structs as immutable params (already efficient) or mut.
Prefer fixed-size arrays and stack values in hot paths. Use @[direct_array_access] in proven-safe hot loops.
Use @[inline] for tiny hot functions. Use -cflags '-march=native -flto'.
Minimize allocations in loops: reuse buffers, use unsafe { arr.reset() } patterns, -autofree or -prealloc for short-lived tools.
Use spawn/thread pools for CPU-bound parallel work (sync.pool).
Use json (compile-time) rather than dynamic x.json2 for known schemas.
Inspect generated C (-keepc) and profile (-profile, perf).