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.
This commit is contained in:
1 parent
324a00c07e
commit
5a2fa689a7
3 files changed
+3
-3
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user