Skip to content

Commit 9b85893

Browse files
authored
fix: switch to re.MatchString(string) instead re.Match([]byte(string)) (#574)
removes heaps allocation, feels more "native"
1 parent b1f0148 commit 9b85893

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

rule/file-header.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ func (r *FileHeaderRule) Apply(file *lint.File, arguments lint.Arguments) []lint
4242
comment := ""
4343
for _, c := range g.List {
4444
text := c.Text
45-
if multiRegexp.Match([]byte(text)) {
45+
if multiRegexp.MatchString(text) {
4646
text = text[2 : len(text)-2]
47-
} else if singleRegexp.Match([]byte(text)) {
47+
} else if singleRegexp.MatchString(text) {
4848
text = text[2:]
4949
}
5050
comment += text
@@ -55,7 +55,7 @@ func (r *FileHeaderRule) Apply(file *lint.File, arguments lint.Arguments) []lint
5555
panic(err.Error())
5656
}
5757

58-
if !regex.Match([]byte(comment)) {
58+
if !regex.MatchString(comment) {
5959
return failure
6060
}
6161
return nil

0 commit comments

Comments
 (0)