Commit b902040
committed
mem: allow using io.WriterTo with a io.LimitedReader
The caller of this function can wrap the io.Reader in a
io.LimitedReader. This happens if some max message size is set. If so,
this `io.WriterTo` check doesn't work anymore. Work around this by
checking if it is maybe a `io.LimitedReader`.
Overall, the problem I'm trying to solve is that the constant
```go
buf := pool.Get(readAllBufSize)
```
32KiB is way too much in our use case. Messages are typically at max
about only 1KiB in size so we always overallocate by ~31KiB in the best
case scenario so we want to use the `io.WriterTo` branch so that we
could appropriately size the buffer.
Signed-off-by: Giedrius Statkevičius <[email protected]>1 parent 7472d57 commit b902040
1 file changed
+12
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
260 | 272 | | |
261 | 273 | | |
262 | 274 | | |
| |||
0 commit comments