diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-24 21:23:08 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-24 21:23:08 +0200 |
| commit | 03ee58c0e018a9493f50ac1cb45bf40899935cf9 (patch) | |
| tree | 1278451cd060620536f39f734e86a95244f1947b | |
| parent | 57f037b78d2836954b0b12142cfd2771142b319b (diff) | |
flamegraph: reuse package-level svg escaper
| -rw-r--r-- | internal/flamegraph/svgwriter.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/internal/flamegraph/svgwriter.go b/internal/flamegraph/svgwriter.go index 5ab8e50..5e3a3fc 100644 --- a/internal/flamegraph/svgwriter.go +++ b/internal/flamegraph/svgwriter.go @@ -8,6 +8,14 @@ import ( "strings" ) +var svgEscaper = strings.NewReplacer( + "&", "&", + "<", "<", + ">", ">", + `"`, """, + "'", "'", +) + type SVGConfig struct { Title string Width int @@ -147,12 +155,5 @@ func flamegraphCSS(cfg SVGConfig) string { } func svgEscape(s string) string { - replacer := strings.NewReplacer( - "&", "&", - "<", "<", - ">", ">", - `"`, """, - "'", "'", - ) - return replacer.Replace(s) + return svgEscaper.Replace(s) } |
