(length int)
| 109 | } |
| 110 | |
| 111 | func (s *Scanner) allocBytes(length int) []byte { |
| 112 | if cap(s.bytesPrealloc) >= length { |
| 113 | res := s.bytesPrealloc[:length:length] |
| 114 | s.bytesPrealloc = s.bytesPrealloc[length:cap(s.bytesPrealloc)] |
| 115 | return res |
| 116 | } |
| 117 | return make([]byte, length) |
| 118 | } |
| 119 | |
| 120 | // buffer returns an empty []byte buffer that can be appended to. Any unused |
| 121 | // portion can be returned later using returnBuffer. |