(length int, errOut *Error)
| 136 | } |
| 137 | |
| 138 | func (b *ByteBuffer) discardFromReader(length int, errOut *Error) bool { |
| 139 | var scratch [8192]byte |
| 140 | for length > 0 { |
| 141 | n := length |
| 142 | if n > len(scratch) { |
| 143 | n = len(scratch) |
| 144 | } |
| 145 | readBytes, err := io.ReadFull(b.reader, scratch[:n]) |
| 146 | length -= readBytes |
| 147 | if err != nil { |
| 148 | if errOut != nil { |
| 149 | if err == io.EOF || err == io.ErrUnexpectedEOF { |
| 150 | *errOut = BufferOutOfBoundError(b.readerIndex, n, readBytes) |
| 151 | } else { |
| 152 | *errOut = DeserializationError(fmt.Sprintf("stream read error: %v", err)) |
| 153 | } |
| 154 | } |
| 155 | return false |
| 156 | } |
| 157 | } |
| 158 | return true |
| 159 | } |
| 160 | |
| 161 | // grow ensures there's space for n more bytes. Hot path is inlined. |
| 162 | func (b *ByteBuffer) grow(n int) { |
no test coverage detected