From 87796d4fa9e49b443c641a80906a242475f22955 Mon Sep 17 00:00:00 2001 From: Kayvan Sylvan Date: Fri, 11 Jul 2025 13:48:30 -0700 Subject: [PATCH] chore: optimize model ID extraction and remove redundant comment ## CHANGES - Remove duplicate comment about reading response body - Preallocate slice capacity in extractModelIDs function - Initialize modelIDs slice with known capacity --- internal/plugins/ai/openai_compatible/direct_models_call.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/plugins/ai/openai_compatible/direct_models_call.go b/internal/plugins/ai/openai_compatible/direct_models_call.go index 05196c1c..d406046a 100644 --- a/internal/plugins/ai/openai_compatible/direct_models_call.go +++ b/internal/plugins/ai/openai_compatible/direct_models_call.go @@ -66,7 +66,6 @@ func (c *Client) DirectlyGetModels(ctx context.Context) ([]string, error) { resp.StatusCode, c.GetName(), bodyString) } - // Read the response body // Read the response body once bodyBytes, err := io.ReadAll(resp.Body) if err != nil { @@ -98,7 +97,7 @@ func (c *Client) DirectlyGetModels(ctx context.Context) ([]string, error) { } func extractModelIDs(models []Model) []string { - var modelIDs []string + modelIDs := make([]string, 0, len(models)) for _, model := range models { modelIDs = append(modelIDs, model.ID) }