Skip to content

Commit

Permalink
Optimize if acceptMForMask is false
Browse files Browse the repository at this point in the history
  • Loading branch information
joneskoo committed Feb 7, 2021
1 parent 43c2d63 commit 0021e8e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ipgrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@ const (

func parseIPPrefix(s string) (prefix netaddr.IPPrefix, err error) {
is := strings.IndexByte(s, '/')
im := strings.IndexByte(s, 'm')
im := -1
if acceptMForMask {
im = strings.IndexByte(s, 'm')
}
// i is position of the separator or end of string if no separator
var i int
switch {
case is >= 0:
i = is
case im >= 0 && acceptMForMask:
case im >= 0:
i = im
default:
i = len(s)
Expand Down

0 comments on commit 0021e8e

Please sign in to comment.