Adopt absl::string_view in function parameters under rtc_base/
This is part of a large-scale effort to increase adoption of
absl::string_view across the WebRTC code base.
This CL converts the majority of "const std::string&"s in function
parameters under rtc_base/ to absl::string_view.
Bug: webrtc:13579
Change-Id: I2b1e3776aa42326aa405f76bb324a2d233b21dca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254081
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Xavier Lepaul‎ <xalep@webrtc.org>
Reviewed-by: Anders Lilienthal <andersc@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36239}
diff --git a/rtc_base/socket_address.h b/rtc_base/socket_address.h
index 570a712..99e14d8 100644
--- a/rtc_base/socket_address.h
+++ b/rtc_base/socket_address.h
@@ -12,6 +12,8 @@
#define RTC_BASE_SOCKET_ADDRESS_H_
#include <string>
+
+#include "absl/strings/string_view.h"
#ifdef WEBRTC_UNIT_TEST
#include <ostream> // no-presubmit-check TODO(webrtc:8982)
#endif // WEBRTC_UNIT_TEST
@@ -34,7 +36,7 @@
// Creates the address with the given host and port. Host may be a
// literal IP string or a hostname to be resolved later.
// DCHECKs that port is in valid range (0 to 2^16-1).
- SocketAddress(const std::string& hostname, int port);
+ SocketAddress(absl::string_view hostname, int port);
// Creates the address with the given IP and port.
// IP is given as an integer in host byte order. V4 only, to be deprecated.
@@ -69,7 +71,7 @@
// Changes the hostname of this address to the given one.
// Does not resolve the address; use Resolve to do so.
- void SetIP(const std::string& hostname);
+ void SetIP(absl::string_view hostname);
// Sets the IP address while retaining the hostname. Useful for bypassing
// DNS for a pre-resolved IP.
@@ -129,7 +131,7 @@
std::string ToResolvedSensitiveString() const;
// Parses hostname:port and [hostname]:port.
- bool FromString(const std::string& str);
+ bool FromString(absl::string_view str);
#ifdef WEBRTC_UNIT_TEST
inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982)