Update GURL accessors to prepare for crbug.com/448174617. This also updates some code to avoid allocations in the future. Note: this CL was written to avoid needing any changes to the internal googleurl for simplicity. Future changes to GURL relevant to this CL: - path() and friends will return string_view - path_piece() and friends will be removed - We are adding GetPath() and friends to return std::strings Protected by no behavior change. PiperOrigin-RevId: 813827458
diff --git a/quiche/quic/tools/quic_url.cc b/quiche/quic/tools/quic_url.cc index 7eaa8c0..de026ef 100644 --- a/quiche/quic/tools/quic_url.cc +++ b/quiche/quic/tools/quic_url.cc
@@ -48,12 +48,11 @@ return ""; } - std::string host = url_.host(); int port = url_.IntPort(); if (port == url::PORT_UNSPECIFIED) { - return host; + return std::string(url_.host()); } - return absl::StrCat(host, ":", port); + return absl::StrCat(url_.host(), ":", port); } std::string QuicUrl::PathParamsQuery() const { @@ -69,7 +68,7 @@ return ""; } - return url_.scheme(); + return std::string(url_.scheme()); } std::string QuicUrl::host() const { @@ -85,7 +84,7 @@ return ""; } - return url_.path(); + return std::string(url_.path()); } uint16_t QuicUrl::port() const {
diff --git a/quiche/quic/tools/web_transport_test_server.cc b/quiche/quic/tools/web_transport_test_server.cc index 7c27156..c1f0707 100644 --- a/quiche/quic/tools/web_transport_test_server.cc +++ b/quiche/quic/tools/web_transport_test_server.cc
@@ -44,7 +44,7 @@ int count = 1; DeviousBatonValue initial_value = quiche::QuicheRandom::GetInstance()->RandUint64() % 256; - std::string query = url.query(); + std::string query = std::string(url.query()); url::Component query_component, key_component, value_component; query_component.begin = 0; query_component.len = query.size();