Using absl::string_view for `uri` in `RTPHeaderExtensionMap` 90/291890/4
authorAdam Bujalski <a.bujalski@samsung.com>
Wed, 12 Apr 2023 08:29:27 +0000 (10:29 +0200)
committerBot Blink <blinkbot@samsung.com>
Tue, 25 Apr 2023 07:47:30 +0000 (07:47 +0000)
Internally RtpHeaderExtensionMap held uri of the extension as
`const char*`. Each extension and its uri was known at compile time.
Later at runtime during then for each packet in `Call::DeliverRtp`
method these `uri` was compared against extension uri carried in RTP
packet. Such comparison lead to repeated computation of string length
for strings known at compile time.

This patch changes `const char*` type to `absl::string_view` type to
cache length of string at compile time.

Bug: https://cam.sprc.samsung.pl/browse/VDGAME-249
Change-Id: I68dc4a41fab8ab07c2719b19f0e760d9940a620f

third_party/webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h
third_party/webrtc/modules/rtp_rtcp/source/rtp_header_extension_map.cc

index 72e5541d37898e9b2858ffb1dea91a1c493a88c8..5ef0283d5d883ef07328dd14482d86882140cbe5 100644 (file)
@@ -62,7 +62,7 @@ class RtpHeaderExtensionMap {
   }
 
  private:
-  bool Register(int id, RTPExtensionType type, const char* uri);
+  bool Register(int id, RTPExtensionType type, absl::string_view uri);
 
   uint8_t ids_[kRtpExtensionNumberOfExtensions];
   bool extmap_allow_mixed_;
index d1eee22a55aab0c6592c5ca87e595331a6b667e7..fdba3a747ed4ae5e9c5416daff69cdb7eb92c69a 100644 (file)
@@ -23,7 +23,7 @@ namespace {
 
 struct ExtensionInfo {
   RTPExtensionType type;
-  const char* uri;
+  absl::string_view uri;
 };
 
 template <typename Extension>
@@ -127,7 +127,7 @@ void RtpHeaderExtensionMap::Deregister(absl::string_view uri) {
 
 bool RtpHeaderExtensionMap::Register(int id,
                                      RTPExtensionType type,
-                                     const char* uri) {
+                                     absl::string_view uri) {
   RTC_DCHECK_GT(type, kRtpExtensionNone);
   RTC_DCHECK_LT(type, kRtpExtensionNumberOfExtensions);