imbajin commented on code in PR #894:
URL: 
https://github.com/apache/hugegraph-toolchain/pull/894#discussion_r4505167652


##########
hugegraph-client-go/hgtransport/hgtransport.go:
##########
@@ -117,7 +117,7 @@ func (c *Client) Perform(req *http.Request) 
(*http.Response, error) {
     var dupReqBody *bytes.Buffer
     if c.logger != nil && c.logger.RequestBodyEnabled() {
         if req.Body != nil && req.Body != http.NoBody {
-            dupReqBody = bytes.NewBuffer(make([]byte, 0, 
int(req.ContentLength)))
+            dupReqBody = new(bytes.Buffer)

Review Comment:
   💡 **Minor: preserve a bounded capacity hint for known-length bodies**
   
   Starting with an empty buffer also drops the existing preallocation for 
positive `ContentLength`, so logging larger, known-length requests now grows 
and copies the buffer repeatedly. A local 1 MiB buffer benchmark showed 
additional allocations. Could we retain a reasonable bounded capacity hint for 
positive lengths while keeping the empty-buffer path for unknown or invalid 
lengths?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to