Optimized map allocation in Replace methods

Initial allocation of several maps as the sizes are known

Signed-off-by: Adrián Orive <adrian.orive.oneca@gmail.com>

Kubernetes-commit: 2299f45f52464beff889fce7be1f66642a92b791
This commit is contained in:
Adrián
2018-10-25 11:42:35 +02:00
committed by Kubernetes Publisher
parent 045bdd8bd8
commit d016aa7909
3 changed files with 3 additions and 3 deletions

2
tools/cache/fifo.go vendored
View File

@@ -297,7 +297,7 @@ func (f *FIFO) Pop(process PopProcessFunc) (interface{}, error) {
// after calling this function. f's queue is reset, too; upon return, it
// will contain the items in the map, in no particular order.
func (f *FIFO) Replace(list []interface{}, resourceVersion string) error {
items := map[string]interface{}{}
items := make(map[string]interface{}, len(list))
for _, item := range list {
key, err := f.keyFunc(item)
if err != nil {