Skip to content
Snippets Groups Projects
Commit 2f52452b authored by takt's avatar takt
Browse files

Fix Less method

parent f23bac7e
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"
...@@ -24,18 +23,20 @@ func (p *Prefix) Dedup() *Prefix { ...@@ -24,18 +23,20 @@ func (p *Prefix) Dedup() *Prefix {
return pfxc.get(p) return pfxc.get(p)
} }
<<<<<<< HEAD
=======
// 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
} }
>>>>>>> 9a2f84b22a4aac17b61e2cdddefd23f228234246
// 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
func (p *Prefix) DedupWithIP() *Prefix { func (p *Prefix) DedupWithIP() *Prefix {
p.addr = p.addr.Dedup() p.addr = p.addr.Dedup()
......
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