remove unnecessary assignments

This commit is contained in:
IncSW 2021-05-03 10:55:17 +03:00
parent e6ff77fe8d
commit c7747ba9b2
No known key found for this signature in database
GPG Key ID: 89876FA64BFB2D57
1 changed files with 4 additions and 14 deletions

View File

@ -131,18 +131,13 @@ func (d *sliceDecoder) decodeStream(s *stream, depth int64, p unsafe.Pointer) er
slice.cap = capacity slice.cap = capacity
slice.len = idx + 1 slice.len = idx + 1
slice.data = data slice.data = data
dst := *(*sliceHeader)(p) dst := (*sliceHeader)(p)
dst.len = idx + 1 dst.len = idx + 1
if dst.len > dst.cap { if dst.len > dst.cap {
dst.data = newArray(d.elemType, dst.len) dst.data = newArray(d.elemType, dst.len)
dst.cap = dst.len dst.cap = dst.len
} }
copySlice(d.elemType, dst, sliceHeader{ copySlice(d.elemType, *dst, *slice)
data: slice.data,
len: slice.len,
cap: slice.cap,
})
*(*sliceHeader)(p) = dst
d.releaseSlice(slice) d.releaseSlice(slice)
s.cursor++ s.cursor++
return nil return nil
@ -247,18 +242,13 @@ func (d *sliceDecoder) decode(buf []byte, cursor, depth int64, p unsafe.Pointer)
slice.cap = capacity slice.cap = capacity
slice.len = idx + 1 slice.len = idx + 1
slice.data = data slice.data = data
dst := *(*sliceHeader)(p) dst := (*sliceHeader)(p)
dst.len = idx + 1 dst.len = idx + 1
if dst.len > dst.cap { if dst.len > dst.cap {
dst.data = newArray(d.elemType, dst.len) dst.data = newArray(d.elemType, dst.len)
dst.cap = dst.len dst.cap = dst.len
} }
copySlice(d.elemType, dst, sliceHeader{ copySlice(d.elemType, *dst, *slice)
data: slice.data,
len: slice.len,
cap: slice.cap,
})
**(**sliceHeader)(unsafe.Pointer(&p)) = dst
d.releaseSlice(slice) d.releaseSlice(slice)
cursor++ cursor++
return cursor, nil return cursor, nil