Each render built a new goldmark converter. For short texts, such as
comments, this was most of the cost. Now `render` reuses converters from
a `sync.Pool`, as the TODO in `SpecializedMarkdown` suggested. Each
converter gets the `RenderInternal` of the render. The HTML output does
not change.
| Benchmark | Before | After | Allocs |
|---|---:|---:|---|
| Comment | 85.0 µs | 46.0 µs | 502 → 207 |
| `BenchmarkMarkdownRender` | 100.5 µs | 62.8 µs | 536 → 241 |
| README | 1.51 ms | 1.50 ms | 9679 → 9384 |
No benchmark got slower (AMD EPYC 9V74, Go 1.27.4, 24 rounds).
Checks:
- `go test ./modules/markup/...` and golangci-lint pass.
- Old and new HTML matched on 20,000 random documents.
- Parallel renders pass with `-race`.
Claude was used for this change. I reviewed and tested it.
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>