diff options
author | kiel barry <kiel.j.barry@gmail.com> | 2018-05-08 17:48:07 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-05-08 17:48:07 +0800 |
commit | a42be3b78dcb70ea3c44ba46c277cf41ef0bba23 (patch) | |
tree | 015fd69b9db3e027af09cced001b5e786b9e59ac /rlp/encode.go | |
parent | 6cf0ab38bd0af77d81aad4c104979cebee9e3e63 (diff) | |
download | dexon-a42be3b78dcb70ea3c44ba46c277cf41ef0bba23.tar dexon-a42be3b78dcb70ea3c44ba46c277cf41ef0bba23.tar.gz dexon-a42be3b78dcb70ea3c44ba46c277cf41ef0bba23.tar.bz2 dexon-a42be3b78dcb70ea3c44ba46c277cf41ef0bba23.tar.lz dexon-a42be3b78dcb70ea3c44ba46c277cf41ef0bba23.tar.xz dexon-a42be3b78dcb70ea3c44ba46c277cf41ef0bba23.tar.zst dexon-a42be3b78dcb70ea3c44ba46c277cf41ef0bba23.zip |
rlp: fix some golint warnings (#16659)
Diffstat (limited to 'rlp/encode.go')
-rw-r--r-- | rlp/encode.go | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/rlp/encode.go b/rlp/encode.go index 44592c2f5..445b4b5b2 100644 --- a/rlp/encode.go +++ b/rlp/encode.go @@ -92,7 +92,7 @@ func Encode(w io.Writer, val interface{}) error { return eb.toWriter(w) } -// EncodeBytes returns the RLP encoding of val. +// EncodeToBytes returns the RLP encoding of val. // Please see the documentation of Encode for the encoding rules. func EncodeToBytes(val interface{}) ([]byte, error) { eb := encbufPool.Get().(*encbuf) @@ -104,7 +104,7 @@ func EncodeToBytes(val interface{}) ([]byte, error) { return eb.toBytes(), nil } -// EncodeReader returns a reader from which the RLP encoding of val +// EncodeToReader returns a reader from which the RLP encoding of val // can be read. The returned size is the total size of the encoded // data. // @@ -151,11 +151,10 @@ func puthead(buf []byte, smalltag, largetag byte, size uint64) int { if size < 56 { buf[0] = smalltag + byte(size) return 1 - } else { - sizesize := putint(buf[1:], size) - buf[0] = largetag + byte(sizesize) - return sizesize + 1 } + sizesize := putint(buf[1:], size) + buf[0] = largetag + byte(sizesize) + return sizesize + 1 } // encbufs are pooled. @@ -218,7 +217,7 @@ func (w *encbuf) list() *listhead { func (w *encbuf) listEnd(lh *listhead) { lh.size = w.size() - lh.offset - lh.size if lh.size < 56 { - w.lhsize += 1 // length encoded into kind tag + w.lhsize++ // length encoded into kind tag } else { w.lhsize += 1 + intsize(uint64(lh.size)) } @@ -322,10 +321,9 @@ func (r *encReader) next() []byte { p := r.buf.str[r.strpos:head.offset] r.strpos += sizebefore return p - } else { - r.lhpos++ - return head.encode(r.buf.sizebuf) } + r.lhpos++ + return head.encode(r.buf.sizebuf) case r.strpos < len(r.buf.str): // String data at the end, after all list headers. @@ -576,9 +574,8 @@ func makePtrWriter(typ reflect.Type) (writer, error) { writer := func(val reflect.Value, w *encbuf) error { if val.IsNil() { return nilfunc(w) - } else { - return etypeinfo.writer(val.Elem(), w) } + return etypeinfo.writer(val.Elem(), w) } return writer, err } |