From ee7f5ffeffe4a15d9e1529d7f038fe5c4fc15e56 Mon Sep 17 00:00:00 2001 From: Boris Atamanovskii Date: Tue, 6 Jan 2026 12:29:10 -0300 Subject: [PATCH] fix: use strings.Builder for efficient string concatenation --- model.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/model.go b/model.go index e73f181efc522de97bc38008e19d858d07006c1e..4d1c3e31bf25ce1e3cef19853c4eb5553f008f19 100644 --- a/model.go +++ b/model.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "iter" + "strings" ) // Usage represents token usage statistics for a model call. @@ -57,11 +58,11 @@ func (r ResponseContent) Reasoning() []ReasoningContent { // ReasoningText returns all reasoning content as a concatenated string. func (r ResponseContent) ReasoningText() string { - var text string + var builder strings.Builder for _, reasoning := range r.Reasoning() { - text += reasoning.Text + builder.WriteString(reasoning.Text) } - return text + return builder.String() } // Files returns all file content parts.