MCPcopy
hub / github.com/CodisLabs/codis / ReadBytes

Method ReadBytes

pkg/utils/bufio2/bufio.go:137–162  ·  view source on GitHub ↗
(delim byte)

Source from the content-addressed store, hash-verified

135}
136
137func (b *Reader) ReadBytes(delim byte) ([]byte, error) {
138 var full [][]byte
139 var last []byte
140 var size int
141 for last == nil {
142 f, err := b.ReadSlice(delim)
143 if err != nil {
144 if err != bufio.ErrBufferFull {
145 return nil, b.err
146 }
147 dup := b.slice.Make(len(f))
148 copy(dup, f)
149 full = append(full, dup)
150 } else {
151 last = f
152 }
153 size += len(f)
154 }
155 var n int
156 var buf = b.slice.Make(size)
157 for _, frag := range full {
158 n += copy(buf[n:], frag)
159 }
160 copy(buf[n:], last)
161 return buf, nil
162}
163
164func (b *Reader) ReadFull(n int) ([]byte, error) {
165 if b.err != nil || n == 0 {

Callers 2

TestReadBytesFunction · 0.80
decodeTextBytesMethod · 0.80

Calls 2

ReadSliceMethod · 0.95
MakeMethod · 0.80

Tested by 1

TestReadBytesFunction · 0.64