Reduce unnecessary Set in updateAllocatedDevices

This commit is contained in:
Ted Yu 2019-11-27 08:48:06 -08:00
parent 7c87b5fb55
commit 86f3bc25e1

View File

@ -602,12 +602,10 @@ func (m *ManagerImpl) updateAllocatedDevices(activePods []*v1.Pod) {
} }
m.mutex.Lock() m.mutex.Lock()
defer m.mutex.Unlock() defer m.mutex.Unlock()
activePodUids := sets.NewString() podsToBeRemoved := m.podDevices.pods()
for _, pod := range activePods { for _, pod := range activePods {
activePodUids.Insert(string(pod.UID)) podsToBeRemoved.Delete(string(pod.UID))
} }
allocatedPodUids := m.podDevices.pods()
podsToBeRemoved := allocatedPodUids.Difference(activePodUids)
if len(podsToBeRemoved) <= 0 { if len(podsToBeRemoved) <= 0 {
return return
} }