MCPcopy Index your code
hub / github.com/codehamr/codehamr / Write

Method Write

internal/tools/bash.go:238–263  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

236}
237
238func (w *headTailBuffer) Write(p []byte) (int, error) {
239 n := len(p)
240 if room := bashOutputHead - len(w.head); room > 0 {
241 take := min(room, len(p))
242 w.head = append(w.head, p[:take]...)
243 p = p[take:]
244 }
245 if len(p) == 0 {
246 return n, nil
247 }
248 if w.ring == nil {
249 w.ring = make([]byte, bashOutputTail)
250 }
251 w.tailBytes += int64(len(p))
252 if len(p) >= bashOutputTail {
253 copy(w.ring, p[len(p)-bashOutputTail:])
254 w.pos = 0
255 return n, nil
256 }
257 k := copy(w.ring[w.pos:], p)
258 w.pos = (w.pos + k) % bashOutputTail
259 if k < len(p) {
260 w.pos = copy(w.ring, p[k:])
261 }
262 return n, nil
263}
264
265// droppedBytes is how many middle bytes the ring discarded; 0 while the whole
266// output still fits head+tail.

Callers 7

newFakeReleaseFunction · 0.80
hashOfFunction · 0.80
writeYAMLFunction · 0.80

Calls

no outgoing calls

Tested by 6

newFakeReleaseFunction · 0.64
hashOfFunction · 0.64