MCPcopy
hub / github.com/IBM/sarama / resize

Method resize

internal/queue/queue.go:22–33  ·  view source on GitHub ↗

resize rebuilds buf with head back at index 0, sized to 2*count but never below minLen so the zero value of Queue grows on first Add.

()

Source from the content-addressed store, hash-verified

20// resize rebuilds buf with head back at index 0, sized to 2*count but never
21// below minLen so the zero value of Queue grows on first Add.
22func (q *Queue[T]) resize() {
23 newBuf := make([]T, max(minLen, q.count<<1))
24 if q.tail > q.head {
25 copy(newBuf, q.buf[q.head:q.tail])
26 } else {
27 n := copy(newBuf, q.buf[q.head:])
28 copy(newBuf[n:], q.buf[:q.tail])
29 }
30 q.head = 0
31 q.tail = q.count
32 q.buf = newBuf
33}
34
35// Add appends elem, growing the buffer if it is full.
36func (q *Queue[T]) Add(elem T) {

Callers 2

AddMethod · 0.95
RemoveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected