mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Merge pull request #44651 from knightXun/string
Automatic merge from submit-queue (batch tested with PRs 44594, 44651) remove strings.compare(), use string native operation I notice we use strings.Compare() in some code, we can remove it and use native operation.
This commit is contained in:
commit
870585e8e1
@ -42,7 +42,7 @@ func ValidateStorageClassUpdate(storageClass, oldStorageClass *storage.StorageCl
|
|||||||
allErrs = append(allErrs, field.Forbidden(field.NewPath("parameters"), "updates to parameters are forbidden."))
|
allErrs = append(allErrs, field.Forbidden(field.NewPath("parameters"), "updates to parameters are forbidden."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Compare(storageClass.Provisioner, oldStorageClass.Provisioner) != 0 {
|
if storageClass.Provisioner != oldStorageClass.Provisioner {
|
||||||
allErrs = append(allErrs, field.Forbidden(field.NewPath("provisioner"), "updates to provisioner are forbidden."))
|
allErrs = append(allErrs, field.Forbidden(field.NewPath("provisioner"), "updates to provisioner are forbidden."))
|
||||||
}
|
}
|
||||||
return allErrs
|
return allErrs
|
||||||
|
@ -622,7 +622,7 @@ func (pc *PCCloud) DiskIsAttached(pdID string, nodeName k8stypes.NodeName) (bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, vm := range disk.VMs {
|
for _, vm := range disk.VMs {
|
||||||
if strings.Compare(vm, vmID) == 0 {
|
if vm == vmID {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2143,7 +2143,7 @@ func TestPrintService(t *testing.T) {
|
|||||||
printService(&test.service, buf, printers.PrintOptions{})
|
printService(&test.service, buf, printers.PrintOptions{})
|
||||||
// We ignore time
|
// We ignore time
|
||||||
if buf.String() != test.expect {
|
if buf.String() != test.expect {
|
||||||
t.Fatalf("Expected: %s, got: %s %d", test.expect, buf.String(), strings.Compare(test.expect, buf.String()))
|
t.Fatalf("Expected: %s, but got: %s", test.expect, buf.String())
|
||||||
}
|
}
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func (s ByPriority) Len() int { return len(s) }
|
|||||||
func (s ByPriority) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
func (s ByPriority) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
func (s ByPriority) Less(i, j int) bool {
|
func (s ByPriority) Less(i, j int) bool {
|
||||||
if s[i].Spec.Priority == s[j].Spec.Priority {
|
if s[i].Spec.Priority == s[j].Spec.Priority {
|
||||||
return strings.Compare(s[i].Name, s[j].Name) < 0
|
return s[i].Name < s[j].Name
|
||||||
}
|
}
|
||||||
return s[i].Spec.Priority < s[j].Spec.Priority
|
return s[i].Spec.Priority < s[j].Spec.Priority
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user