Skip to content

Commit

Permalink
fix: switch to re.MatchString(string) instead re.Match([]byte(string)) (
Browse files Browse the repository at this point in the history
#574)

removes heaps allocation, feels more "native"
  • Loading branch information
butuzov authored Sep 12, 2021
1 parent b1f0148 commit 9b85893
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rule/file-header.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9b85893

Please sign in to comment.