canInsertBeforeHead returns true if it's possible to insert an entry of size of need before the head of the queue
(need int)
| 259 | |
| 260 | // canInsertBeforeHead returns true if it's possible to insert an entry of size of need before the head of the queue |
| 261 | func (q *BytesQueue) canInsertBeforeHead(need int) bool { |
| 262 | if q.full { |
| 263 | return false |
| 264 | } |
| 265 | if q.tail >= q.head { |
| 266 | return q.head-leftMarginIndex == need || q.head-leftMarginIndex >= need+minimumHeaderSize |
| 267 | } |
| 268 | return q.head-q.tail == need || q.head-q.tail >= need+minimumHeaderSize |
| 269 | } |