From 4347cf898c66441f1c8f65ece369cd86ec8f321c Mon Sep 17 00:00:00 2001 From: "Iskander (Alex) Sharipov" Date: Thu, 6 Jan 2022 20:10:42 +0300 Subject: [PATCH] pkg/result/processors: compile nolint regexp only once (#2463) --- pkg/result/processors/nolint.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/result/processors/nolint.go b/pkg/result/processors/nolint.go index c8c44838e3e1..12ae0fc2d546 100644 --- a/pkg/result/processors/nolint.go +++ b/pkg/result/processors/nolint.go @@ -17,6 +17,7 @@ import ( ) var nolintDebugf = logutils.Debug("nolint") +var nolintRe = regexp.MustCompile(`^nolint( |:|$)`) type ignoredRange struct { linters []string @@ -234,7 +235,7 @@ func (p *Nolint) extractFileCommentsInlineRanges(fset *token.FileSet, comments . func (p *Nolint) extractInlineRangeFromComment(text string, g ast.Node, fset *token.FileSet) *ignoredRange { text = strings.TrimLeft(text, "/ ") - if ok, _ := regexp.MatchString(`^nolint( |:|$)`, text); !ok { + if !nolintRe.MatchString(text) { return nil }