More panicky type assertions

This commit is contained in:
Justin Li 2014-07-15 22:48:04 -04:00
parent 5ccb42a0c7
commit c745c791a5

View file

@ -57,12 +57,7 @@ func (p peerList) Len() int {
}
func (p peerList) Less(i, j int) bool {
if peer1, ok := p[i].(bencode.Dict); ok {
if peer2, ok := p[j].(bencode.Dict); ok {
return peer1["peer id"].(string) < peer2["peer id"].(string)
}
}
return false
return p[i].(bencode.Dict)["peer id"].(string) < p[j].(bencode.Dict)["peer id"].(string)
}
func (p peerList) Swap(i, j int) {