Skip to content

Commit

Permalink
Merge pull request #20 from alex/optimize-reflect-valueof
Browse files Browse the repository at this point in the history
Avoid calling reflect.ValueOf repeatedly
  • Loading branch information
ianlopshire authored Aug 26, 2019
2 parents d470bcf + a578b80 commit 37aafdf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ func (d *Decoder) Decode(v interface{}) error {
}

if rv.Elem().Kind() == reflect.Slice {
return d.readLines(reflect.ValueOf(v).Elem())
return d.readLines(rv.Elem())
}

err, ok := d.readLine(reflect.ValueOf(v))
err, ok := d.readLine(rv)
if d.done && err == nil && !ok {
// d.done means we've reached the end of the file. err == nil && !ok
// indicates that there was no data to read, so we propagate an io.EOF
Expand Down

0 comments on commit 37aafdf

Please sign in to comment.