From 521b8632b642d6337fec466b6411663519795277 Mon Sep 17 00:00:00 2001 From: Tommi Date: Mon, 12 Feb 2024 14:52:13 +0100 Subject: [PATCH] Change type of candidate type names from char[] to string_view Bug: none Change-Id: I57fcfd486bf4e2fb15288614b0e81f00b10e120a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/337443 Reviewed-by: Harald Alvestrand Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#41721} --- api/candidate.cc | 9 +++++---- api/candidate.h | 8 ++++---- pc/rtc_stats_collector_unittest.cc | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/api/candidate.cc b/api/candidate.cc index 865f8e5787..4311556233 100644 --- a/api/candidate.cc +++ b/api/candidate.cc @@ -10,6 +10,7 @@ #include "api/candidate.h" +#include "absl/base/attributes.h" #include "rtc_base/helpers.h" #include "rtc_base/ip_address.h" #include "rtc_base/logging.h" @@ -17,10 +18,10 @@ namespace cricket { -const char LOCAL_PORT_TYPE[] = "local"; -const char STUN_PORT_TYPE[] = "stun"; -const char PRFLX_PORT_TYPE[] = "prflx"; -const char RELAY_PORT_TYPE[] = "relay"; +ABSL_CONST_INIT const absl::string_view LOCAL_PORT_TYPE = "local"; +ABSL_CONST_INIT const absl::string_view STUN_PORT_TYPE = "stun"; +ABSL_CONST_INIT const absl::string_view PRFLX_PORT_TYPE = "prflx"; +ABSL_CONST_INIT const absl::string_view RELAY_PORT_TYPE = "relay"; Candidate::Candidate() : id_(rtc::CreateRandomString(8)), diff --git a/api/candidate.h b/api/candidate.h index 3fefd1114b..12b1512e72 100644 --- a/api/candidate.h +++ b/api/candidate.h @@ -32,10 +32,10 @@ namespace cricket { // TODO(tommi): These are temporarily here, moved from `port.h` and will // eventually be removed once we use enums instead of strings for these values. -RTC_EXPORT extern const char LOCAL_PORT_TYPE[]; -RTC_EXPORT extern const char STUN_PORT_TYPE[]; -RTC_EXPORT extern const char PRFLX_PORT_TYPE[]; -RTC_EXPORT extern const char RELAY_PORT_TYPE[]; +RTC_EXPORT extern const absl::string_view LOCAL_PORT_TYPE; +RTC_EXPORT extern const absl::string_view STUN_PORT_TYPE; +RTC_EXPORT extern const absl::string_view PRFLX_PORT_TYPE; +RTC_EXPORT extern const absl::string_view RELAY_PORT_TYPE; // TURN servers are limited to 32 in accordance with // https://w3c.github.io/webrtc-pc/#dom-rtcconfiguration-iceservers diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index 03512bbcde..98cbd2d7e3 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -212,7 +212,7 @@ std::unique_ptr CreateFakeCandidate( int port, const std::string& protocol, const rtc::AdapterType adapter_type, - const std::string& candidate_type, + const absl::string_view candidate_type, uint32_t priority, const rtc::AdapterType underlying_type_for_vpn = rtc::ADAPTER_TYPE_UNKNOWN) {