Avoid Format.asprintf in segment_to_string hot path
segment_to_string was called millions of times during HTML generation
(one of the top allocation sites: ~60% of minor heap allocation
according to statmemprof). It used Format.asprintf "%a%s" with a
pretty-printer that either does nothing (for Module/Page/LeafPage/
File/SourcePage kinds — the common case) or emits "<kind>-".
Replace with a direct match: return name unchanged for passthrough
kinds, otherwise concatenate prefix directly. Eliminates Format
buffer allocation per call.
Results:
- core.odocl html-generate: 45.7 GB -> 23.4 GB (-49% alloc)
- core.odocl html-generate: 9.53s -> 7.33s (-23%)
- stdlib.odocl html-generate: 1.74s -> 0.52s (-70%)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>