bencode: Simplify `(*Decoder).parseListInterface()` (#656)
Preserve as much type as possible (it'll be converted to an `interface{}` anyway, but we can return `[]interface{}` instead of `{}interface` here).
This commit is contained in:
parent
f3a9ea5aa9
commit
d43769dc15
|
@ -661,18 +661,12 @@ func (d *Decoder) parseDictInterface() interface{} {
|
|||
return dict
|
||||
}
|
||||
|
||||
func (d *Decoder) parseListInterface() interface{} {
|
||||
var list []interface{}
|
||||
for {
|
||||
valuei, ok := d.parseValueInterface()
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
|
||||
func (d *Decoder) parseListInterface() (list []interface{}) {
|
||||
list = []interface{}{}
|
||||
valuei, ok := d.parseValueInterface()
|
||||
for ok {
|
||||
list = append(list, valuei)
|
||||
valuei, ok = d.parseValueInterface()
|
||||
}
|
||||
if list == nil {
|
||||
list = make([]interface{}, 0)
|
||||
}
|
||||
return list
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue