Skip to content

Commit

Permalink
refactor(evpn): remove const todo from util func
Browse files Browse the repository at this point in the history
use input array length instead

Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Aug 14, 2023
1 parent 4284207 commit 924ea3f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions network/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ func parseIPAndPrefix(ipPrefixStr string) (*pc.IPPrefix, error) {

// Function to parse an array of IP prefixes from strings to pb.IPPrefix messages
func parseIPPrefixes(ipPrefixesStr []string) ([]*pc.IPPrefix, error) {
const maxPrefixes = 10 // Update this to your expected maximum number of prefixes
var ipPrefixes = make([]*pc.IPPrefix, 0, maxPrefixes)
ipPrefixes := make([]*pc.IPPrefix, len(ipPrefixesStr))

for _, ipPrefixStr := range ipPrefixesStr {
for i, ipPrefixStr := range ipPrefixesStr {
ipPrefix, err := parseIPAndPrefix(ipPrefixStr)
if err != nil {
return nil, fmt.Errorf("failed to parse IP prefix: %v", err)
}
ipPrefixes = append(ipPrefixes, ipPrefix)
ipPrefixes[i] = ipPrefix
}

return ipPrefixes, nil
}

0 comments on commit 924ea3f

Please sign in to comment.