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:
Kubernetes Submit Queue 2017-04-20 14:08:59 -07:00 committed by GitHub
commit 870585e8e1
4 changed files with 4 additions and 4 deletions

View File

@ -42,7 +42,7 @@ func ValidateStorageClassUpdate(storageClass, oldStorageClass *storage.StorageCl
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."))
}
return allErrs

View File

@ -622,7 +622,7 @@ func (pc *PCCloud) DiskIsAttached(pdID string, nodeName k8stypes.NodeName) (bool
}
for _, vm := range disk.VMs {
if strings.Compare(vm, vmID) == 0 {
if vm == vmID {
return true, nil
}
}

View File

@ -2143,7 +2143,7 @@ func TestPrintService(t *testing.T) {
printService(&test.service, buf, printers.PrintOptions{})
// We ignore time
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()
}

View File

@ -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) Less(i, j int) bool {
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
}