Skip to content

Commit

Permalink
Remove redundant conditions in unmarshalSlice()
Browse files Browse the repository at this point in the history
fi.size is checked 3 times, one time is enough.
  • Loading branch information
aler9 committed Sep 30, 2023
1 parent 1261cd9 commit fb51aa1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion marshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func (u *unmarshaller) unmarshalSlice(v reflect.Value, fi *fieldInstance) error
return fmt.Errorf("out of memory: requestedSize=%d", length)
}

if fi.size != 0 && fi.size%8 == 0 && u.rbits%8 == 0 && elemType.Kind() == reflect.Uint8 && fi.size == 8 {
if u.rbits%8 == 0 && elemType.Kind() == reflect.Uint8 && fi.size == 8 {
totalSize := length * uint64(fi.size) / 8
capacity := totalSize
if u.dst.GetType() != BoxTypeMdat() && capacity > maxInitialSliceCapacity {
Expand Down

0 comments on commit fb51aa1

Please sign in to comment.