Skip to content
Snippets Groups Projects
Unverified Commit 02bfd001 authored by Christoph Petrausch's avatar Christoph Petrausch Committed by GitHub
Browse files

Merge pull request #234 from bio-routing/fix/pfxdedup

Fix/pfxdedup
parents 9a2f84b2 2f52452b
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
gonet "net" gonet "net"
"strconv" "strconv"
"strings" "strings"
"unsafe"
"github.com/bio-routing/bio-rd/net/api" "github.com/bio-routing/bio-rd/net/api"
"github.com/google/btree" "github.com/google/btree"
...@@ -26,11 +25,16 @@ func (p *Prefix) Dedup() *Prefix { ...@@ -26,11 +25,16 @@ func (p *Prefix) Dedup() *Prefix {
// Less compares prefixes for use in btree.Btree // Less compares prefixes for use in btree.Btree
func (p *Prefix) Less(other btree.Item) bool { func (p *Prefix) Less(other btree.Item) bool {
if uintptr(unsafe.Pointer(p.addr)) < uintptr(unsafe.Pointer(other.(*Prefix).addr)) { switch p.addr.Compare(other.(*Prefix).addr) {
case 0:
return p.pfxlen < other.(*Prefix).pfxlen
case -1:
return true return true
case 1:
return false
} }
return p.pfxlen < other.(*Prefix).pfxlen return false
} }
// DedupWithIP gets a copy of Prefix from the cache and dedups the IP part // DedupWithIP gets a copy of Prefix from the cache and dedups the IP part
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment