MCPcopy Index your code
hub / github.com/CrowdStrike/csproto / stringToBytes

Method stringToBytes

encoder.go:384–391  ·  view source on GitHub ↗

stringToBytes is an optimized convert from a string to a []byte using unsafe.Pointer

(s string)

Source from the content-addressed store, hash-verified

382
383// stringToBytes is an optimized convert from a string to a []byte using unsafe.Pointer
384func (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.

Callers 1

EncodeStringMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected