diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-09-29 15:18:08 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-09-29 15:18:08 +0900 |
commit | bafc6171067c3f836a4d140d6308fb676608b35e (patch) | |
tree | ea0cb4ee97d7be527af53caac7d91bd721eb803d /policy/policy.go | |
parent | b802501d27a901a52926169955b172f6395ad5c5 (diff) |
policy: improve ipPrefixCalculate performance slightly
Contains() is very slow so let's avoid it if possible.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'policy/policy.go')
-rw-r--r-- | policy/policy.go | 2 |
1 files changed, 1 insertions, 1 deletions
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 ( |