()
| 241 | } |
| 242 | |
| 243 | func (q *queue) maybeCompactLocked() { |
| 244 | if q.head == 0 { |
| 245 | return |
| 246 | } |
| 247 | if q.head >= len(q.items) { |
| 248 | q.items = nil |
| 249 | q.head = 0 |
| 250 | return |
| 251 | } |
| 252 | if q.head < 1024 && q.head*2 < len(q.items) { |
| 253 | return |
| 254 | } |
| 255 | q.items = append([]queueItem(nil), q.items[q.head:]...) |
| 256 | q.head = 0 |
| 257 | } |