mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-30 03:51:43 +02:00
controller(listVMs): avoid copy of each element when filtering (#401)
* controller(listVMs): avoid copy of each element when filtering * Explain the change
This commit is contained in:
@@ -349,13 +349,14 @@ func (controller *Controller) listVMs(ctx *gin.Context) responder.Responder {
|
||||
vms := []v1.VM{}
|
||||
|
||||
Outer:
|
||||
for _, vm := range allVMs {
|
||||
// Use index-based loop to avoid per-iteration copies of v1.VM
|
||||
for i := range allVMs {
|
||||
for _, filter := range filters {
|
||||
if !vm.Match(filter) {
|
||||
if !allVMs[i].Match(filter) {
|
||||
continue Outer
|
||||
}
|
||||
}
|
||||
vms = append(vms, vm)
|
||||
vms = append(vms, allVMs[i])
|
||||
}
|
||||
|
||||
return responder.JSON(http.StatusOK, vms)
|
||||
|
||||
Reference in New Issue
Block a user