Explorar el Código

Merge pull request #42773 from thaJeztah/simplify_version_compare

api/types/versions: simplify compare if versions are equal
Sebastiaan van Stijn hace 3 años
padre
commit
2740726ce1
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      api/types/versions/compare.go

+ 3 - 0
api/types/versions/compare.go

@@ -8,6 +8,9 @@ import (
 // compare compares two version strings
 // compare compares two version strings
 // returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
 // returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
 func compare(v1, v2 string) int {
 func compare(v1, v2 string) int {
+	if v1 == v2 {
+		return 0
+	}
 	var (
 	var (
 		currTab  = strings.Split(v1, ".")
 		currTab  = strings.Split(v1, ".")
 		otherTab = strings.Split(v2, ".")
 		otherTab = strings.Split(v2, ".")