Skip to content

Commit

Permalink
use more efficient strings comparison
Browse files Browse the repository at this point in the history
Signed-off-by: belo4ya <[email protected]>
  • Loading branch information
belo4ya committed Feb 16, 2024
1 parent 3e03d16 commit 457d37b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/scheduler/api/devices/nvidia/vgpu/device_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (gs *GPUDevices) AddResource(pod *v1.Pod) {
break
}
for index, gsdevice := range gs.Device {
if strings.Compare(gsdevice.UUID, deviceused.UUID) == 0 {
if gsdevice.UUID == deviceused.UUID {
klog.V(4).Infoln("VGPU recording pod", pod.Name, "device", deviceused)
gs.Device[index].UsedMem += uint(deviceused.Usedmem)
gs.Device[index].UsedNum++
Expand All @@ -156,7 +156,7 @@ func (gs *GPUDevices) SubResource(pod *v1.Pod) {
break
}
for index, gsdevice := range gs.Device {
if strings.Compare(gsdevice.UUID, deviceused.UUID) == 0 {
if gsdevice.UUID == deviceused.UUID {
klog.V(4).Infoln("VGPU subsctracting pod", pod.Name, "device", deviceused)
gs.Device[index].UsedMem -= uint(deviceused.Usedmem)
gs.Device[index].UsedNum--
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/api/devices/nvidia/vgpu/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func checkType(annos map[string]string, d GPUDevice, n ContainerDeviceRequest) b
if !strings.Contains(d.Type, n.Type) {
return false
}
if strings.Compare(n.Type, NvidiaGPUDevice) == 0 {
if n.Type == NvidiaGPUDevice {
return checkGPUtype(annos, d.Type)
}
klog.Errorf("Unrecognized device %v", n.Type)
Expand Down

0 comments on commit 457d37b

Please sign in to comment.