mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-02-12 06:55:08 -05:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user