mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
more clear
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
dc12b75db6
commit
fe7ae65985
1 changed files with 7 additions and 5 deletions
|
|
@ -380,9 +380,12 @@ func (b *blockWriter) full() bool {
|
||||||
//
|
//
|
||||||
// This function is safe to be called multiple times.
|
// This function is safe to be called multiple times.
|
||||||
func (b *blockWriter) finish() []byte {
|
func (b *blockWriter) finish() []byte {
|
||||||
restartsLen := len(b.restarts)
|
var (
|
||||||
extra := restartsLen*2 + 1
|
restartsLen = len(b.restarts)
|
||||||
var buf []byte
|
restartsOff = len(b.data)
|
||||||
|
extra = restartsLen*2 + 1
|
||||||
|
buf []byte
|
||||||
|
)
|
||||||
|
|
||||||
if cap(b.data)-len(b.data) >= extra {
|
if cap(b.data)-len(b.data) >= extra {
|
||||||
// Enough capacity, just reslice; data is already in place.
|
// Enough capacity, just reslice; data is already in place.
|
||||||
|
|
@ -393,9 +396,8 @@ func (b *blockWriter) finish() []byte {
|
||||||
copy(buf, b.data)
|
copy(buf, b.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
restartsOffset := len(b.data)
|
|
||||||
for i, restart := range b.restarts {
|
for i, restart := range b.restarts {
|
||||||
binary.BigEndian.PutUint16(buf[restartsOffset+2*i:], restart)
|
binary.BigEndian.PutUint16(buf[restartsOff+2*i:], restart)
|
||||||
}
|
}
|
||||||
buf[len(buf)-1] = byte(restartsLen)
|
buf[len(buf)-1] = byte(restartsLen)
|
||||||
return buf
|
return buf
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue