From bafc6171067c3f836a4d140d6308fb676608b35e Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 29 Sep 2015 15:18:08 +0900 Subject: policy: improve ipPrefixCalculate performance slightly Contains() is very slow so let's avoid it if possible. Signed-off-by: FUJITA Tomonori --- policy/policy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/policy/policy.go b/policy/policy.go index 1fd2f017..80598c9e 100644 --- a/policy/policy.go +++ b/policy/policy.go @@ -1407,7 +1407,7 @@ func ipPrefixCalculate(path *table.Path, cPrefix Prefix) bool { return false } - return cPrefix.Prefix.Contains(pAddr) && (cPrefix.MasklengthRangeMin <= pMasklen && pMasklen <= cPrefix.MasklengthRangeMax) + return (cPrefix.MasklengthRangeMin <= pMasklen && pMasklen <= cPrefix.MasklengthRangeMax) && cPrefix.Prefix.Contains(pAddr) } const ( -- cgit v1.2.3