MCPcopy
hub / github.com/kovidgoyal/kitty / Write

Method Write

tools/utils/base85/base85.go:224–249  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

222}
223
224func (e *encoder) Write(p []byte) (n int, err error) {
225 if e.err != nil {
226 return 0, e.err
227 }
228
229 for len(p) >= len(e.bufin)-e.fill {
230 //copy len(e.buf) - fill bytes into e.buf to make it full
231 to_copy := len(e.bufin) - e.fill
232 copy(e.bufin[e.fill:], p[:to_copy])
233 p = p[to_copy:]
234
235 //write the encoded whole buffer
236 encodeChunk(e.encoded[:], e.bufin[:])
237 _, e.err = e.w.Write(e.encoded[:])
238 if e.err != nil {
239 return n, e.err
240 }
241 n += 4
242 e.fill = 0
243 }
244 for i := 0; i < len(p); i++ {
245 e.bufin[e.fill] = p[i]
246 e.fill += 1
247 }
248 return n, e.w.(*bufio.Writer).Flush()
249}
250
251func (e *encoder) Close() error {
252 if e.err == nil && e.fill > 0 {

Callers 3

TestTarExtractFunction · 0.45
NewStreamDecompressorFunction · 0.45
CloseMethod · 0.45

Calls 2

encodeChunkFunction · 0.85
FlushMethod · 0.65

Tested by 1

TestTarExtractFunction · 0.36