evict removes the specified number of bytes from the beginning of the buffer.
(count int)
| 77 | |
| 78 | // evict removes the specified number of bytes from the beginning of the buffer. |
| 79 | func (rb *ringBuffer) evict(count int) { |
| 80 | if count >= rb.Size() { |
| 81 | // Evict everything |
| 82 | rb.start = 0 |
| 83 | rb.end = -1 |
| 84 | return |
| 85 | } |
| 86 | |
| 87 | rb.start = (rb.start + count) % len(rb.buffer) |
| 88 | // Buffer remains non-empty after partial eviction |
| 89 | } |
| 90 | |
| 91 | // ReadLast returns the last n bytes from the buffer. |
| 92 | // If n is greater than the available data, returns an error. |