Allocate podFields map with a correct hint for size

This commit is contained in:
Wojciech Tyczynski 2016-10-17 15:07:15 +02:00
parent 422121f93a
commit c6b098068d

View File

@ -192,11 +192,14 @@ func NodeNameTriggerFunc(obj runtime.Object) []storage.MatchValue {
// PodToSelectableFields returns a field set that represents the object
// TODO: fields are not labels, and the validation rules for them do not apply.
func PodToSelectableFields(pod *api.Pod) fields.Set {
podSpecificFieldsSet := fields.Set{
"spec.nodeName": pod.Spec.NodeName,
"spec.restartPolicy": string(pod.Spec.RestartPolicy),
"status.phase": string(pod.Status.Phase),
}
// The purpose of allocation with a given number of elements is to reduce
// amount of allocations needed to create the fields.Set. If you add any
// field here or the number of object-meta related fields changes, this should
// be adjusted.
podSpecificFieldsSet := make(fields.Set, 5)
podSpecificFieldsSet["spec.nodeName"] = pod.Spec.NodeName
podSpecificFieldsSet["spec.restartPolicy"] = string(pod.Spec.RestartPolicy)
podSpecificFieldsSet["status.phase"] = string(pod.Status.Phase)
return generic.AddObjectMetaFieldsSet(podSpecificFieldsSet, &pod.ObjectMeta, true)
}