MCPcopy Create free account
hub / github.com/cloudwego/netpoll / Bytes

Method Bytes

nocopy_linkbuffer.go:652–666  ·  view source on GitHub ↗

------------------------------------------ implement connection interface ------------------------------------------ Bytes returns all the readable bytes of this LinkBuffer.

()

Source from the content-addressed store, hash-verified

650
651// Bytes returns all the readable bytes of this LinkBuffer.
652func (b *UnsafeLinkBuffer) Bytes() []byte {
653 node, flush := b.read, b.flush
654 if node == flush {
655 return node.buf[node.off:]
656 }
657 n := 0
658 p := dirtmake.Bytes(b.Len(), b.Len())
659 for ; node != flush; node = node.next {
660 if node.Len() > 0 {
661 n += copy(p[n:], node.buf[node.off:])
662 }
663 }
664 n += copy(p[n:], flush.buf[flush.off:])
665 return p[:n]
666}
667
668// GetBytes will read and fill the slice p as much as possible.
669// If p is not passed, return all readable bytes.

Callers 7

FlushMethod · 0.45
mallocFunction · 0.45
NextMethod · 0.45
readBinaryMethod · 0.45

Calls 2

LenMethod · 0.95
LenMethod · 0.65

Tested by 3