MCPcopy Create free account
hub / github.com/blues/note / refill

Method refill

jsonxt/stream.go:144–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

142}
143
144func (dec *Decoder) refill() error {
145 // Make room to read more into the buffer.
146 // First slide down data already consumed.
147 if dec.scanp > 0 {
148 dec.scanned += int64(dec.scanp)
149 n := copy(dec.buf, dec.buf[dec.scanp:])
150 dec.buf = dec.buf[:n]
151 dec.scanp = 0
152 }
153
154 // Grow buffer if not large enough.
155 const minRead = 512
156 if cap(dec.buf)-len(dec.buf) < minRead {
157 newBuf := make([]byte, len(dec.buf), 2*cap(dec.buf)+minRead)
158 copy(newBuf, dec.buf)
159 dec.buf = newBuf
160 }
161
162 // Read. Delay error for next iteration (after scan).
163 n, err := dec.r.Read(dec.buf[len(dec.buf):cap(dec.buf)])
164 dec.buf = dec.buf[0 : len(dec.buf)+n]
165
166 return err
167}
168
169func nonSpace(b []byte) bool {
170 for _, c := range b {

Callers 2

readValueMethod · 0.95
peekMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected