Skip to content

Commit

Permalink
Fix Less method
Browse files Browse the repository at this point in the history
  • Loading branch information
takt committed Oct 31, 2019
1 parent f23bac7 commit 2f52452
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions net/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
gonet "net"
"strconv"
"strings"
"unsafe"

"github.com/bio-routing/bio-rd/net/api"
"github.com/google/btree"
Expand All @@ -24,18 +23,20 @@ func (p *Prefix) Dedup() *Prefix {
return pfxc.get(p)
}

<<<<<<< HEAD
=======
// Less compares prefixes for use in btree.Btree
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
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
func (p *Prefix) DedupWithIP() *Prefix {
p.addr = p.addr.Dedup()
Expand Down

0 comments on commit 2f52452

Please sign in to comment.