Skip to content

Commit

Permalink
Return ref to rule in slice to avoid allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
hmarr committed Oct 27, 2022
1 parent 291d009 commit a8d3c95
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions codeowners.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ type Ruleset []Rule
// last matching rule takes precedence.
func (r Ruleset) Match(path string) (*Rule, error) {
for i := len(r) - 1; i >= 0; i-- {
rule := r[i]
rule := &r[i]
match, err := rule.Match(path)
if match || err != nil {
return &rule, err
return rule, err
}
}
return nil, nil
Expand Down

0 comments on commit a8d3c95

Please sign in to comment.