mirror of https://github.com/status-im/consul.git
Small premature optimization in `isUUID()`.
If the length isn't `36`, return `false` immediately before firing up the regexp engine.
This commit is contained in:
parent
0a3492595b
commit
c5e140c79d
|
@ -14,6 +14,11 @@ var validUUID = regexp.MustCompile(`(?i)^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f
|
|||
|
||||
// isUUID returns true if the given string is a valid UUID.
|
||||
func isUUID(str string) bool {
|
||||
const uuidLen = 36
|
||||
if len(str) != uuidLen {
|
||||
return false
|
||||
}
|
||||
|
||||
return validUUID.MatchString(str)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue