diff --git a/internal/gcp/checks/checker.go b/internal/gcp/checks/checker.go
index 1ba8d87..884a299 100644
--- a/internal/gcp/checks/checker.go
+++ b/internal/gcp/checks/checker.go
@@ -10,6 +10,7 @@
"context"
"log/slog"
"net/http"
+ "strings"
"golang.org/x/oauth2"
oauth2google "golang.org/x/oauth2/google"
@@ -137,11 +138,11 @@
// the given text and optional promptParts. If the text represents an input to an LLM,
// promptParts should be empty.
func (c *Checker) newClassifyRequest(text string, promptParts []llm.Part) *ClassifyContentRequest {
- var prompt string
+ var prompt strings.Builder
for _, p := range promptParts {
switch p := p.(type) {
case llm.Text:
- prompt += string(p)
+ prompt.WriteString(string(p))
default:
// Not fatal; the prompt is only used for additional context.
c.lg.Info("checks.Checker: prompt type not supported", "part", p)
@@ -149,7 +150,7 @@
}
return &ClassifyContentRequest{
Context: &RequestContext{
- Prompt: prompt,
+ Prompt: prompt.String(),
},
Input: &InputContent{
TextInput: &TextInput{
diff --git a/internal/htmlutil/split.go b/internal/htmlutil/split.go
index 9cd2dd9..17c00b0 100644
--- a/internal/htmlutil/split.go
+++ b/internal/htmlutil/split.go
@@ -71,17 +71,18 @@
flush := func(level int, id string) bool {
if level > 1 {
// Construct a title that gives the sequence of heading titles (h1 title > h2 title > ...).
- title := titles[0]
+ var title strings.Builder
+ title.WriteString(titles[0])
for _, s := range titles[1:] {
if s != "" {
- title += " > " + s
+ title.WriteString(" > " + s)
}
}
// Emit the section.
txt := strings.TrimSpace(text.String())
if txt != "" && lastID != "" {
- if !yield(&Section{Title: title, ID: lastID, Text: txt}) {
+ if !yield(&Section{Title: title.String(), ID: lastID, Text: txt}) {
return false
}
}