Skip to content

Commit 36ea7d1

Browse files
committed
lint: preallocate slices
1 parent bca935d commit 36ea7d1

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ func (a *agent) Stream(ctx context.Context, opts AgentStreamCall) (*AgentResult,
841841
}
842842

843843
func (a *agent) prepareTools(tools []AgentTool, activeTools []string, disableAllTools bool) []Tool {
844-
var preparedTools []Tool
844+
preparedTools := make([]Tool, 0, len(tools))
845845

846846
// If explicitly disabling all tools, return no tools
847847
if disableAllTools {

content.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ func NewUserMessage(prompt string, files ...FilePart) Message {
469469
}
470470

471471
func NewSystemMessage(prompt ...string) Message {
472-
var content []MessagePart
472+
content := make([]MessagePart, 0, len(prompt))
473473
for _, p := range prompt {
474474
content = append(content, TextPart{Text: p})
475475
}

providers/openai.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ func (o openAiLanguageModel) Generate(ctx context.Context, call ai.Call) (*ai.Re
436436
return nil, errors.New("no response generated")
437437
}
438438
choice := response.Choices[0]
439-
var content []ai.Content
439+
content := make([]ai.Content, 0, 1+len(choice.Message.ToolCalls)+len(choice.Message.Annotations))
440440
text := choice.Message.Content
441441
if text != "" {
442442
content = append(content, ai.TextContent{

0 commit comments

Comments
 (0)