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
This commit is contained in:
Kayvan Sylvan
2025-07-11 13:48:30 -07:00
parent e1945a0b62
commit 87796d4fa9

View File

@@ -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)
}