Avoid rescanning buffered data in chunked OHTTP and indeterminate-length BHTTP.

The logic buffers an incomplete chunk or section until the rest of it arrives. After each call the logic compared the buffer with the checkpoint to decide whether to copy it. When nothing was consumed, the checkpoint is the buffer itself, but the comparison still read every buffered byte. This leads to unnecessary repeated comparisons in cases of long incomplete chunks being fed in small slices at a time.

The comparison is changed to now look only at the address and size. When the address and size match, the checkpoint is the buffer itself, so the buffer holds the same bytes as before in every case.

Also adds google3-only benchmarks (excluded from the QUICHE export) that feed an incomplete chunk in 64-byte slices to the chunked OHTTP gateway and client and to both indeterminate-length BHTTP decoders. Time to buffer the chunk, before and after this change (`-c opt`):

| Buffered | Before | After |
|---|---|---|
| 64 KiB | 0.33–0.58 ms | 0.035–0.039 ms |
| 1 MiB | 66–71 ms | 0.55–0.60 ms |
| 16 MiB | 18.7–18.9 s | 9.2–10.2 ms |

PiperOrigin-RevId: 1028362606
diff --git a/quiche/binary_http/binary_http_message.cc b/quiche/binary_http/binary_http_message.cc
index b4a6a88..fd33699 100644
--- a/quiche/binary_http/binary_http_message.cc
+++ b/quiche/binary_http/binary_http_message.cc
@@ -277,9 +277,12 @@
 // Buffers the checkpoint.
 void BufferChunkedDecodingCheckpoint(absl::string_view checkpoint,
                                      std::string& buffer) {
-  if (buffer != checkpoint) {
-    buffer.assign(checkpoint);
+  // If the checkpoint is already the whole buffer, there is nothing to copy.
+  if (checkpoint.data() == buffer.data() &&
+      checkpoint.size() == buffer.size()) {
+    return;
   }
+  buffer.assign(checkpoint);
 }
 
 // Decodes the fields in the reader. Calls the field_handler for each field
diff --git a/quiche/oblivious_http/oblivious_http_client.h b/quiche/oblivious_http/oblivious_http_client.h
index 1c4a47a..39ce999 100644
--- a/quiche/oblivious_http/oblivious_http_client.h
+++ b/quiche/oblivious_http/oblivious_http_client.h
@@ -171,9 +171,12 @@
 
   // Buffers the response checkpoint.
   void BufferResponseCheckpoint(absl::string_view response_checkpoint) {
-    if (response_buffer_ != response_checkpoint) {
-      response_buffer_.assign(response_checkpoint);
+    // If the checkpoint is already the whole buffer, there is nothing to copy.
+    if (response_checkpoint.data() == response_buffer_.data() &&
+        response_checkpoint.size() == response_buffer_.size()) {
+      return;
     }
+    response_buffer_.assign(response_checkpoint);
   }
 
   absl::StatusOr<std::string> EncryptRequestChunkImpl(
diff --git a/quiche/oblivious_http/oblivious_http_gateway.h b/quiche/oblivious_http/oblivious_http_gateway.h
index 1206ea0..7784992 100644
--- a/quiche/oblivious_http/oblivious_http_gateway.h
+++ b/quiche/oblivious_http/oblivious_http_gateway.h
@@ -167,9 +167,12 @@
   }
   // Buffers the request checkpoint.
   void BufferRequestCheckpoint() {
-    if (request_buffer_ != request_checkpoint_view_) {
-      request_buffer_ = std::string(request_checkpoint_view_);
+    // If the checkpoint is already the whole buffer, there is nothing to copy.
+    if (request_checkpoint_view_.data() == request_buffer_.data() &&
+        request_checkpoint_view_.size() == request_buffer_.size()) {
+      return;
     }
+    request_buffer_ = std::string(request_checkpoint_view_);
   }
   absl::StatusOr<std::string> EncryptResponseChunk(
       absl::string_view plaintext_payload, bool is_final_chunk);