stringToBytes is an optimized convert from a string to a []byte using unsafe.Pointer
(s string)
| 382 | |
| 383 | // stringToBytes is an optimized convert from a string to a []byte using unsafe.Pointer |
| 384 | func (e *Encoder) stringToBytes(s string) []byte { |
| 385 | return *(*[]byte)(unsafe.Pointer( |
| 386 | &struct { |
| 387 | string |
| 388 | Cap int |
| 389 | }{s, len(s)}, |
| 390 | )) |
| 391 | } |
| 392 | |
| 393 | // EncodeTag combines tag and wireType then encodes the result into dest using the Protobuf |
| 394 | // varint format and returns the number of bytes written. |