mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
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:
parent
8bd5a46016
commit
7b3638ea77
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user