Skip to content

Commit bdc2af3

Browse files
authored
controller(listVMs): reduce allocations (#400)
* controller(listVMs): reduce allocations * Declare an empty, non-nil slice to return [] when no objects are found
1 parent be869f1 commit bdc2af3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/controller/api_vms.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ func (controller *Controller) listVMs(ctx *gin.Context) responder.Responder {
344344
return responder.Code(http.StatusInternalServerError)
345345
}
346346

347-
vms := make([]v1.VM, 0, len(allVMs))
347+
// Declare an empty, non-nil slice to
348+
// return [] when no objects are found
349+
vms := []v1.VM{}
348350

349351
Outer:
350352
for _, vm := range allVMs {

0 commit comments

Comments
 (0)