feat(NPC): minor performance improvement

Don't continue the loop if we've already matched.
This commit is contained in:
Aaron U'Ren 2021-07-24 18:18:56 -05:00
parent 5156f878d6
commit 031d75265b

View File

@ -441,11 +441,13 @@ func (npc *NetworkPolicyController) cleanupStaleRules(activePolicyChains, active
}
if _, ok := activePolicyChains[chain]; !ok {
cleanupPolicyChains = append(cleanupPolicyChains, chain)
continue
}
}
if strings.HasPrefix(chain, kubePodFirewallChainPrefix) {
if _, ok := activePodFwChains[chain]; !ok {
cleanupPodFwChains = append(cleanupPodFwChains, chain)
continue
}
}
}