mirror of
https://github.com/mgechev/revive.git
synced 2025-03-17 20:57:58 +02:00
fix: switch to re.MatchString(string) instead re.Match([]byte(string)) (#574)
removes heaps allocation, feels more "native"
This commit is contained in:
parent
b1f01484c2
commit
9b85893ff8
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user