1
0
mirror of https://github.com/mgechev/revive.git synced 2025-03-17 20:57:58 +02:00

fix: switch to re.MatchString(string) instead re.Match([]byte(string)) (#574)

removes heaps allocation, feels more "native"
This commit is contained in:
Oleg Butuzov 2021-09-13 02:05:42 +03:00 committed by GitHub
parent b1f01484c2
commit 9b85893ff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,9 +42,9 @@ func (r *FileHeaderRule) Apply(file *lint.File, arguments lint.Arguments) []lint
comment := ""
for _, c := range g.List {
text := c.Text
if multiRegexp.Match([]byte(text)) {
if multiRegexp.MatchString(text) {
text = text[2 : len(text)-2]
} else if singleRegexp.Match([]byte(text)) {
} else if singleRegexp.MatchString(text) {
text = text[2:]
}
comment += text
@ -55,7 +55,7 @@ func (r *FileHeaderRule) Apply(file *lint.File, arguments lint.Arguments) []lint
panic(err.Error())
}
if !regex.Match([]byte(comment)) {
if !regex.MatchString(comment) {
return failure
}
return nil