summaryrefslogtreecommitdiff
path: root/internal/flamegraph
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-24 21:23:08 +0200
committerPaul Buetow <paul@buetow.org>2026-02-24 21:23:08 +0200
commit03ee58c0e018a9493f50ac1cb45bf40899935cf9 (patch)
tree1278451cd060620536f39f734e86a95244f1947b /internal/flamegraph
parent57f037b78d2836954b0b12142cfd2771142b319b (diff)
flamegraph: reuse package-level svg escaper
Diffstat (limited to 'internal/flamegraph')
-rw-r--r--internal/flamegraph/svgwriter.go17
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(
+ "&", "&amp;",
+ "<", "&lt;",
+ ">", "&gt;",
+ `"`, "&quot;",
+ "'", "&apos;",
+)
+
type SVGConfig struct {
Title string
Width int
@@ -147,12 +155,5 @@ func flamegraphCSS(cfg SVGConfig) string {
}
func svgEscape(s string) string {
- replacer := strings.NewReplacer(
- "&", "&amp;",
- "<", "&lt;",
- ">", "&gt;",
- `"`, "&quot;",
- "'", "&apos;",
- )
- return replacer.Replace(s)
+ return svgEscaper.Replace(s)
}