summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-12-02 10:55:55 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-12-02 12:53:01 +0900
commitb83d3cc802cdaa69b8c77b6db54aa8fe4e472ba7 (patch)
tree811a854f3c065f2fa86c444e0156fcf683650e9d
parentacad9314f0a607ca0b417b044a95150921a431c7 (diff)
table: improve implicitWithdraw()
remove one loop. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--table/destination.go27
1 files changed, 10 insertions, 17 deletions
diff --git a/table/destination.go b/table/destination.go
index 8d020df5..7485c987 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -333,15 +333,13 @@ func (dest *Destination) explicitWithdraw() paths {
// Known paths will no longer have paths whose new version is present in
// new paths.
func (dest *Destination) implicitWithdraw() {
- newPaths := dest.newPathList
- knownPaths := dest.knownPathList
-
- newKnownPaths := make([]*Path, 0, len(knownPaths))
- for _, newPath := range newPaths {
- if newPath.NoImplicitWithdraw {
- continue
- }
- for _, path := range knownPaths {
+ newKnownPaths := make([]*Path, 0, len(dest.knownPathList))
+ for _, path := range dest.knownPathList {
+ found := false
+ for _, newPath := range dest.newPathList {
+ if newPath.NoImplicitWithdraw {
+ continue
+ }
// Here we just check if source is same and not check if path
// version num. as newPaths are implicit withdrawal of old
// paths and when doing RouteRefresh (not EnhancedRouteRefresh)
@@ -352,19 +350,14 @@ func (dest *Destination) implicitWithdraw() {
"Key": dest.GetNlri().String(),
"Path": path,
}).Debug("Implicit withdrawal of old path, since we have learned new path from the same peer")
- // just use as a flag whether to leave in knownPathList
- path.IsWithdraw = true
+
+ found = true
break
}
}
- }
-
- for _, path := range dest.knownPathList {
- if !path.IsWithdraw {
+ if !found {
newKnownPaths = append(newKnownPaths, path)
}
- // we've used the flag. flag it down.
- path.IsWithdraw = false
}
dest.knownPathList = newKnownPaths
}