mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #103775 from jyz0309/optimze
Optimize the for range code in types.go
This commit is contained in:
commit
3ee63b09b7
@ -746,10 +746,8 @@ func calculateResource(pod *v1.Pod) (res Resource, non0CPU int64, non0Mem int64)
|
|||||||
|
|
||||||
// updateUsedPorts updates the UsedPorts of NodeInfo.
|
// updateUsedPorts updates the UsedPorts of NodeInfo.
|
||||||
func (n *NodeInfo) updateUsedPorts(pod *v1.Pod, add bool) {
|
func (n *NodeInfo) updateUsedPorts(pod *v1.Pod, add bool) {
|
||||||
for j := range pod.Spec.Containers {
|
for _, container := range pod.Spec.Containers {
|
||||||
container := &pod.Spec.Containers[j]
|
for _, podPort := range container.Ports {
|
||||||
for k := range container.Ports {
|
|
||||||
podPort := &container.Ports[k]
|
|
||||||
if add {
|
if add {
|
||||||
n.UsedPorts.Add(podPort.HostIP, string(podPort.Protocol), podPort.HostPort)
|
n.UsedPorts.Add(podPort.HostIP, string(podPort.Protocol), podPort.HostPort)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user