simplify s[:] to s where s is a slice

Found using https://go-critic.github.io/overview#unslice-ref
This commit is contained in:
Iskander Sharipov 2018-09-14 00:35:08 +03:00 committed by John C. Vernaleo
parent e9c7a5ac64
commit 0886f1e5c1
4 changed files with 5 additions and 5 deletions

View file

@ -120,7 +120,7 @@ func dbFetchVersion(dbTx database.Tx, key []byte) uint32 {
return 0
}
return byteOrder.Uint32(serialized[:])
return byteOrder.Uint32(serialized)
}
// dbPutVersion uses an existing database transaction to update the provided
@ -943,7 +943,7 @@ func serializeBestChainState(state bestChainState) []byte {
byteOrder.PutUint32(serializedData[offset:], workSumBytesLen)
offset += 4
copy(serializedData[offset:], workSumBytes)
return serializedData[:]
return serializedData
}
// deserializeBestChainState deserializes the passed serialized best chain

View file

@ -474,7 +474,7 @@ func (s *blockStore) writeBlock(rawBlock []byte) (blockLocation, error) {
_, _ = hasher.Write(scratch[:])
// Serialized block.
if err := s.writeData(rawBlock[:], "block"); err != nil {
if err := s.writeData(rawBlock, "block"); err != nil {
return blockLocation{}, err
}
_, _ = hasher.Write(rawBlock)

View file

@ -68,7 +68,7 @@ func (fr *fixedReader) Read(p []byte) (n int, err error) {
func newFixedReader(max int, buf []byte) io.Reader {
b := make([]byte, max)
if buf != nil {
copy(b[:], buf)
copy(b, buf)
}
iobuf := bytes.NewBuffer(b)

View file

@ -401,7 +401,7 @@ func ReadMessageWithEncodingN(r io.Reader, pver uint32, btcnet BitcoinNet,
// Test checksum.
checksum := chainhash.DoubleHashB(payload)[0:4]
if !bytes.Equal(checksum[:], hdr.checksum[:]) {
if !bytes.Equal(checksum, hdr.checksum[:]) {
str := fmt.Sprintf("payload checksum failed - header "+
"indicates %v, but actual checksum is %v.",
hdr.checksum, checksum)