fishy commented on code in PR #3057:
URL: https://github.com/apache/thrift/pull/3057#discussion_r2585820335
##########
lib/go/thrift/binary_protocol.go:
##########
@@ -597,14 +597,18 @@ func safeReadBytes(size int32, trans io.Reader) ([]byte,
error) {
if size < 0 {
return nil, nil
}
- if size > bytes.MinRead {
- // Use bytes.Buffer to prevent allocating size bytes when size
is very large
- buf := new(bytes.Buffer)
- _, err := io.CopyN(buf, trans, int64(size))
- return buf.Bytes(), err
- }
- // Allocate size bytes
- b := make([]byte, size)
- n, err := io.ReadFull(trans, b)
- return b[:n], err
+
+ // Fast path for reads smaller than 10 MiB that only allocates exactly
+ // what is asked for.
+ const readLimit = 10 * 1024 * 1024
Review Comment:
Based on the conversation we had on this PR, the consensus is that we should
make this configurable. Please implement this in TConfiguration instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]