perf: avoid unnecessary byte/string conversion (#10012)
We can use alternative functions to avoid unnecessary byte/string conversion calls and reduce allocations. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
parent
19de8af350
commit
d02ba28b96
4 changed files with 8 additions and 8 deletions
|
|
@ -143,7 +143,7 @@ func ValidMethod(method string) bool {
|
|||
|
||||
// ValidHeader checks is the provided string satisfies the header's name regex
|
||||
func ValidHeader(header string) bool {
|
||||
return headerRegexp.Match([]byte(header))
|
||||
return headerRegexp.MatchString(header)
|
||||
}
|
||||
|
||||
// ValidCacheDuration checks if the provided string is a valid cache duration
|
||||
|
|
@ -159,13 +159,13 @@ func ValidCacheDuration(duration string) bool {
|
|||
if len(element) == 0 {
|
||||
continue
|
||||
}
|
||||
if statusCodeRegex.Match([]byte(element)) {
|
||||
if statusCodeRegex.MatchString(element) {
|
||||
if seenDuration {
|
||||
return false // code after duration
|
||||
}
|
||||
continue
|
||||
}
|
||||
if durationRegex.Match([]byte(element)) {
|
||||
if durationRegex.MatchString(element) {
|
||||
seenDuration = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue