diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-02-29 16:53:01 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-02-29 16:53:01 -0800 |
commit | d6998affcf413291fd615c88df958ea85baf481e (patch) | |
tree | 9c4246ed0f2325f6589abc3a5399ea69cb804f0d /table | |
parent | 1f6e2d490b6dc354197d33c187e24842c9673396 (diff) |
cli: delete duplicated code
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/path.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/table/path.go b/table/path.go index e48b7258..dd510692 100644 --- a/table/path.go +++ b/table/path.go @@ -398,17 +398,17 @@ func (path *Path) GetNlri() bgp.AddrPrefixInterface { return path.OriginInfo().nlri } -type attrs []bgp.PathAttributeInterface +type PathAttrs []bgp.PathAttributeInterface -func (a attrs) Len() int { +func (a PathAttrs) Len() int { return len(a) } -func (a attrs) Swap(i, j int) { +func (a PathAttrs) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a attrs) Less(i, j int) bool { +func (a PathAttrs) Less(i, j int) bool { return a[i].GetType() < a[j].GetType() } @@ -421,7 +421,7 @@ func (path *Path) GetPathAttrs() []bgp.PathAttributeInterface { deleted.Flag(uint(t)) } if p.parent == nil { - list := make([]bgp.PathAttributeInterface, 0, len(p.pathAttrs)) + list := PathAttrs(make([]bgp.PathAttributeInterface, 0, len(p.pathAttrs))) // we assume that the original pathAttrs are // in order, that is, other bgp speakers send // attributes in order. @@ -440,9 +440,7 @@ func (path *Path) GetPathAttrs() []bgp.PathAttributeInterface { for _, m := range modified { list = append(list, m) } - var sorted attrs - sorted = list - sort.Sort(sorted) + sort.Sort(list) } return list } else { |