From baa16931fd93d3f927975a4d83c02e52a44a3abc Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 13 Jun 2016 20:12:03 +0200 Subject: collapse if --- bencode/bencode.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'bencode/bencode.go') diff --git a/bencode/bencode.go b/bencode/bencode.go index 062e980..2c2bdfc 100644 --- a/bencode/bencode.go +++ b/bencode/bencode.go @@ -172,11 +172,9 @@ func (d *decodeState) unmarshalDict(v reflect.Value) { } } } - if ih := v.FieldByName("InfoHash"); ih.IsValid() { - if infoEnd > infoOff { - sum := sha1.Sum(d.data[infoOff:infoEnd]) - ih.SetBytes(sum[:]) - } + if ih := v.FieldByName("InfoHash"); ih.IsValid() && infoEnd > infoOff { + sum := sha1.Sum(d.data[infoOff:infoEnd]) + ih.SetBytes(sum[:]) } d.off++ } -- cgit v1.2.3