refactor: replace (*regexp.Regexp).Match on (*regexp.Regexp).MatchString (#1617)

This PR change one method of regexp.Regexp struct with a similar one,
as result code produce less allocations on heap.
pull/1612/head
Oleg Butuzov 5 years ago committed by GitHub
parent 324a00c07e
commit 5a2fa689a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -212,7 +212,7 @@ func validLoginName(u string) bool {
if u == "" {
return false
}
return !reInvalidLoginName.Match([]byte(u))
return !reInvalidLoginName.MatchString(u)
}
// UpdateAccount updates the repository entry for a.PublicId with the

@ -301,7 +301,7 @@ func HandleAttributeFlags(c *base.Command, suffix, fullField string, sepFields [
case strings.HasPrefix(field.Value, `"`): // explicitly quoted string
val = strings.Trim(field.Value, `"`)
case jsonNumberRegex.Match([]byte(strings.Trim(field.Value, `"`))): // number
case jsonNumberRegex.MatchString(strings.Trim(field.Value, `"`)): // number
// Same logic as above
if strings.Contains(field.Value, ".") {
val, err = strconv.ParseFloat(field.Value, 64)

@ -183,7 +183,7 @@ func ValidId(i Id, prefixes ...string) bool {
continue
}
id = strings.TrimPrefix(id, prefix)
if !reInvalidID.Match([]byte(id)) {
if !reInvalidID.MatchString(id) {
return true
}
}

Loading…
Cancel
Save