Use absl::string_view in SDP-related utilities
A step towards reduced copying in SDP parsing. Bug: None Change-Id: I3a5d89f483c1809929b7160b563c67b040c9df41 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233080 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35122}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
8afd22f286
commit
d4aa3a3196
@ -27,14 +27,14 @@ Candidate::Candidate()
|
||||
network_cost_(0) {}
|
||||
|
||||
Candidate::Candidate(int component,
|
||||
const std::string& protocol,
|
||||
absl::string_view protocol,
|
||||
const rtc::SocketAddress& address,
|
||||
uint32_t priority,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const std::string& type,
|
||||
absl::string_view username,
|
||||
absl::string_view password,
|
||||
absl::string_view type,
|
||||
uint32_t generation,
|
||||
const std::string& foundation,
|
||||
absl::string_view foundation,
|
||||
uint16_t network_id,
|
||||
uint16_t network_cost)
|
||||
: id_(rtc::CreateRandomString(8)),
|
||||
@ -153,4 +153,11 @@ Candidate Candidate::ToSanitizedCopy(bool use_hostname_address,
|
||||
return copy;
|
||||
}
|
||||
|
||||
void Candidate::Assign(std::string& s, absl::string_view view) {
|
||||
// Assigning via a temporary object, like s = std::string(view), results in
|
||||
// binary size bloat. To avoid that, extract pointer and size from the
|
||||
// string view, and use std::string::assign method.
|
||||
s.assign(view.data(), view.size());
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
Reference in New Issue
Block a user