altman08 commented on code in PR #3686:
URL: https://github.com/apache/brpc/pull/3686#discussion_r4420455430


##########
src/butil/iobuf.h:
##########
@@ -534,6 +534,20 @@ class IOBufCutter {
     // Returns pointer to the character, nullptr on empty
     const void* fetch1();
 
+    // Peek the unconsumed part of the current reference without copying.
+    // Load the next reference if needed; return empty on exhausted input.
+    StringPiece front_block();

Review Comment:
   My use case is to peek at N bytes without consuming them. I first check 
whether the contiguous data at the current cursor is large enough. If so, I use 
it directly; otherwise, I fall back to fetch() with a temporary buffer. That 
way, I only need to prepare the temporary buffer when the data spans multiple 
blocks.



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