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

Method GetBytes

nocopy_linkbuffer.go:670–694  ·  view source on GitHub ↗

GetBytes will read and fill the slice p as much as possible. If p is not passed, return all readable bytes.

(p [][]byte)

Source from the content-addressed store, hash-verified

668// GetBytes will read and fill the slice p as much as possible.
669// If p is not passed, return all readable bytes.
670func (b *UnsafeLinkBuffer) GetBytes(p [][]byte) (vs [][]byte) {
671 node, flush := b.read, b.flush
672 if len(p) == 0 {
673 n := 0
674 for ; node != flush; node = node.next {
675 n++
676 }
677 node = b.read
678 p = make([][]byte, n)
679 }
680 var i int
681 for i = 0; node != flush && i < len(p); node = node.next {
682 if node.Len() > 0 {
683 node.setFlag(flagReadExposed)
684 p[i] = node.buf[node.off:]
685 i++
686 }
687 }
688 if i < len(p) {
689 flush.setFlag(flagReadExposed)
690 p[i] = flush.buf[flush.off:]
691 i++
692 }
693 return p[:i]
694}
695
696// book will grow and malloc buffer to hold data.
697//

Callers 4

TestLinkBufferFunction · 0.45
TestLinkBufferGetBytesFunction · 0.45
outputsMethod · 0.45
flushMethod · 0.45

Calls 2

setFlagMethod · 0.80
LenMethod · 0.65

Tested by 2

TestLinkBufferFunction · 0.36
TestLinkBufferGetBytesFunction · 0.36