Skip to content

Commit

Permalink
pkg/result/processors: compile nolint regexp only once (golangci#2463)
Browse files Browse the repository at this point in the history
  • Loading branch information
quasilyte authored and SeigeC committed Apr 4, 2023
1 parent 4849a55 commit 4347cf8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/result/processors/nolint.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
)

var nolintDebugf = logutils.Debug("nolint")
var nolintRe = regexp.MustCompile(`^nolint( |:|$)`)

type ignoredRange struct {
linters []string
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 4347cf8

Please sign in to comment.