From 9b85893ff80ac28f5a9adbf7938eca2d94a821eb Mon Sep 17 00:00:00 2001 From: Oleg Butuzov Date: Mon, 13 Sep 2021 02:05:42 +0300 Subject: [PATCH] fix: switch to re.MatchString(string) instead re.Match([]byte(string)) (#574) removes heaps allocation, feels more "native" --- rule/file-header.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rule/file-header.go b/rule/file-header.go index 7855c85..8fc89e8 100644 --- a/rule/file-header.go +++ b/rule/file-header.go @@ -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