File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -225,18 +225,17 @@ func (client *AWSClient) getInstancesInService(insIDtoIP map[string]string) ([]s
225
225
}
226
226
227
227
func prepareBatches (maxItems int , items []string ) [][]string {
228
- var batches [][]string
228
+ totalBatches := (len (items ) + maxItems - 1 ) / maxItems
229
+ batches := make ([][]string , 0 , totalBatches )
229
230
230
- min := func (a , b int ) int {
231
- if a <= b {
232
- return a
231
+ for i := 0 ; i < len (items ); i += maxItems {
232
+ end := i + maxItems
233
+ if end > len (items ) {
234
+ end = len (items )
233
235
}
234
- return b
236
+ batches = append ( batches , items [ i : end ])
235
237
}
236
238
237
- for i := 0 ; i < len (items ); i += maxItems {
238
- batches = append (batches , items [i :min (i + maxItems , len (items ))])
239
- }
240
239
return batches
241
240
}
242
241
You can’t perform that action at this time.
0 commit comments