summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-29 15:18:08 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-29 15:18:08 +0900
commitbafc6171067c3f836a4d140d6308fb676608b35e (patch)
treeea0cb4ee97d7be527af53caac7d91bd721eb803d
parentb802501d27a901a52926169955b172f6395ad5c5 (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>
-rw-r--r--policy/policy.go2
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 (