Revert removal of some structured bindings and selection statements with initializers.
Revert part of cl/387364180. At that time these C++17 features were banned in
Chromium and did not compile. They have been allowed since then, see:
* structured bindings
+ https://crrev.com/c/3356325/
+ https://groups.google.com/a/chromium.org/g/cxx/c/ExfSorNLNf4
* selection statements with initializers:
+ https://crrev.com/c/3360661
+ https://groups.google.com/a/chromium.org/g/cxx/c/4GP43nftePE
Note that the initializer cannot be moved back into the if statement in
OgHttp2Session::ResumeStream() because a line accessing `it` has been added
afterwards since.
PiperOrigin-RevId: 428049860
diff --git a/http2/adapter/oghttp2_session.cc b/http2/adapter/oghttp2_session.cc
index a3dd8b8..eef7a5f 100644
--- a/http2/adapter/oghttp2_session.cc
+++ b/http2/adapter/oghttp2_session.cc
@@ -1,7 +1,6 @@
#include "http2/adapter/oghttp2_session.h"
#include <cstdint>
-#include <tuple>
#include <utility>
#include "absl/memory/memory.h"
@@ -791,9 +790,7 @@
static_cast<int32_t>(max_frame_payload_)});
while (connection_can_write == SendResult::SEND_OK && available_window > 0 &&
state.outbound_body != nullptr && !state.data_deferred) {
- int64_t length;
- bool end_data;
- std::tie(length, end_data) =
+ auto [length, end_data] =
state.outbound_body->SelectPayloadLength(available_window);
QUICHE_VLOG(2) << "WriteForStream | length: " << length
<< " end_data: " << end_data
@@ -885,9 +882,7 @@
while (!sequence.empty()) {
MetadataSource& source = *sequence.front();
- int64_t written;
- bool end_metadata;
- std::tie(written, end_metadata) =
+ auto [written, end_metadata] =
source.Pack(payload_buffer.get(), max_payload_size);
if (written < 0) {
// Did not touch the connection, so perhaps writes are still possible.
@@ -1589,8 +1584,7 @@
void OgHttp2Session::MarkDataBuffered(Http2StreamId stream_id, size_t bytes) {
connection_window_manager_.MarkDataBuffered(bytes);
- auto it = stream_map_.find(stream_id);
- if (it != stream_map_.end()) {
+ if (auto it = stream_map_.find(stream_id); it != stream_map_.end()) {
it->second.window_manager.MarkDataBuffered(bytes);
}
}
@@ -1601,9 +1595,7 @@
[this, stream_id](size_t window_update_delta) {
SendWindowUpdate(stream_id, window_update_delta);
};
- absl::flat_hash_map<Http2StreamId, StreamState>::iterator iter;
- bool inserted;
- std::tie(iter, inserted) = stream_map_.try_emplace(
+ auto [iter, inserted] = stream_map_.try_emplace(
stream_id, StreamState(initial_stream_receive_window_,
initial_stream_send_window_, std::move(listener)));
if (inserted) {
diff --git a/http2/adapter/test_frame_sequence.cc b/http2/adapter/test_frame_sequence.cc
index 074e3dd..ed9018a 100644
--- a/http2/adapter/test_frame_sequence.cc
+++ b/http2/adapter/test_frame_sequence.cc
@@ -12,9 +12,8 @@
std::vector<Header> ToHeaders(
absl::Span<const std::pair<absl::string_view, absl::string_view>> headers) {
std::vector<Header> out;
- for (const auto& header : headers) {
- out.push_back(
- std::make_pair(HeaderRep(header.first), HeaderRep(header.second)));
+ for (auto [name, value] : headers) {
+ out.push_back(std::make_pair(HeaderRep(name), HeaderRep(value)));
}
return out;
}