Avoid string concatenation when comparing pods.

Pod comparison in (*NodeInfo).Filter was using GetPodFullName before
comparing pod names. This is a concatenation of pod name and pod
namespace, and it is significantly faster to compare name & namespace
instead.
This commit is contained in:
Jonathan Basseri 2017-12-19 16:32:34 -08:00
parent 8bd5a46016
commit 7b3638ea77

View File

@ -510,12 +510,11 @@ func getPodKey(pod *v1.Pod) (string, error) {
// matches NodeInfo.node and the pod is not found in the pods list. Otherwise,
// returns true.
func (n *NodeInfo) Filter(pod *v1.Pod) bool {
pFullName := util.GetPodFullName(pod)
if pod.Spec.NodeName != n.node.Name {
return true
}
for _, p := range n.pods {
if util.GetPodFullName(p) == pFullName {
if p.Name == pod.Name && p.Namespace == pod.Namespace {
return true
}
}