MCPcopy Create free account
hub / github.com/cel-expr/cel-go / trackNetworkContainsCIDRStringCost

Function trackNetworkContainsCIDRStringCost

ext/network.go:778–785  ·  view source on GitHub ↗
(args []ref.Val, result ref.Val)

Source from the content-addressed store, hash-verified

776}
777
778func trackNetworkContainsCIDRStringCost(args []ref.Val, result ref.Val) *uint64 {
779 cidrSize := cost.ActualSize(args[0])
780 otherSize := cost.ActualSize(args[1])
781 total := cost.SafeMultiplyByFactor(cost.SafeAdd(cidrSize, cidrSize), cost.StringCostFactor)
782 total = cost.SafeAdd(total, cost.SafeMultiplyByFactor(cidrSize, cost.StringCostFactor), 1)
783 total = cost.SafeAdd(total, cost.SafeMultiplyByFactor(otherSize, cost.StringCostFactor))
784 return &total
785}
786
787// networkParseCostModel models ip(string) and cidr(string): an IP's length is its address bytes
788// (4 or 16) and a CIDR's is the bytes of its prefix (0 to 16); both strategies size them by that

Callers

nothing calls this directly

Calls 3

ActualSizeFunction · 0.92
SafeMultiplyByFactorFunction · 0.92
SafeAddFunction · 0.92

Tested by

no test coverage detected