From 03ee58c0e018a9493f50ac1cb45bf40899935cf9 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 24 Feb 2026 21:23:08 +0200 Subject: flamegraph: reuse package-level svg escaper --- internal/flamegraph/svgwriter.go | 17 +++++++++-------- 1 file 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) } -- cgit v1.2.3