MCPcopy
hub / github.com/TarsCloud/TarsGo / WriteInt16

Method WriteInt16

tars/protocol/codec/codec.go:225–241  ·  view source on GitHub ↗

WriteInt16 write the int16 with the tag.

(data int16, tag byte)

Source from the content-addressed store, hash-verified

223
224// WriteInt16 write the int16 with the tag.
225func (b *Buffer) WriteInt16(data int16, tag byte) error {
226 var err error
227 if data >= math.MinInt8 && data <= math.MaxInt8 {
228 if err = b.WriteInt8(int8(data), tag); err != nil {
229 return err
230 }
231 } else {
232 if err = b.WriteHead(SHORT, tag); err != nil {
233 return err
234 }
235
236 if err = bWriteU16(b.buf, uint16(data)); err != nil {
237 return err
238 }
239 }
240 return nil
241}
242
243// WriteUint16 write uint16 with the tag.
244func (b *Buffer) WriteUint16(data uint16, tag byte) error {

Callers 7

WriteUint8Method · 0.95
WriteInt32Method · 0.95
TestInt16Function · 0.95
TestInt16_2Function · 0.95
WriteToMethod · 0.80
WriteToMethod · 0.80
putBaseMethod · 0.80

Calls 3

WriteInt8Method · 0.95
WriteHeadMethod · 0.95
bWriteU16Function · 0.85

Tested by 2

TestInt16Function · 0.76
TestInt16_2Function · 0.76