diff options
Diffstat (limited to 'internal/flamegraph')
| -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) } |
