Commit 0b68faf6 authored by Mygod's avatar Mygod

Fix Subnet ordering

parent 7978bced
...@@ -26,7 +26,7 @@ class Subnet(val address: InetAddress, val prefixSize: Int) extends Comparable[S ...@@ -26,7 +26,7 @@ class Subnet(val address: InetAddress, val prefixSize: Int) extends Comparable[S
var result = addrThis lengthCompare addrThat.length // IPv4 address goes first var result = addrThis lengthCompare addrThat.length // IPv4 address goes first
if (result != 0) return result if (result != 0) return result
for ((x, y) <- addrThis zip addrThat) { for ((x, y) <- addrThis zip addrThat) {
result = x compare y result = (x & 0xFF) compare (y & 0xFF) // undo sign extension of signed byte
if (result != 0) return result if (result != 0) return result
} }
prefixSize compare that.prefixSize prefixSize compare that.prefixSize
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment