Merge pull request #85688 from yutedz/pods-to-rm

Reduce unnecessary Set in updateAllocatedDevices
This commit is contained in:
Kubernetes Prow Robot 2019-12-02 17:07:26 -08:00 committed by GitHub
commit 57b6b287d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -606,12 +606,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
} }