io: refactoring for using WriteVarBytes instead of WriteLE

goal is to be consistent with C# implementation.
For writing []byte WriteBytes used and for byte - WriteVarByte.
This commit is contained in:
Vsevolod Brekelov 2019-11-22 13:34:06 +03:00
parent d02673c112
commit 03ff2976ed
20 changed files with 33 additions and 34 deletions

View file

@ -93,18 +93,18 @@ func (w *BinWriter) WriteVarUint(val uint64) {
}
// WriteVarBytes writes a variable byte into the underlying io.Writer without prefix.
func (w *BinWriter) WriteVarBytes(b []byte) {
// WriteBytes writes a variable byte into the underlying io.Writer without prefix.
func (w *BinWriter) WriteBytes(b []byte) {
w.WriteLE(b)
}
// WriteBytes writes a variable length byte array into the underlying io.Writer.
func (w *BinWriter) WriteBytes(b []byte) {
// WriteVarBytes writes a variable length byte array into the underlying io.Writer.
func (w *BinWriter) WriteVarBytes(b []byte) {
w.WriteVarUint(uint64(len(b)))
w.WriteLE(b)
}
// WriteString writes a variable length string into the underlying io.Writer.
func (w *BinWriter) WriteString(s string) {
w.WriteBytes([]byte(s))
w.WriteVarBytes([]byte(s))
}