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}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
1a08096998
commit
7fa9057a05
@ -12,6 +12,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "rtc_base/arraysize.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
@ -77,8 +78,8 @@ void hex_encode_with_delimiter(char* buffer,
|
||||
|
||||
} // namespace
|
||||
|
||||
std::string hex_encode(const std::string& str) {
|
||||
return hex_encode(str.c_str(), str.size());
|
||||
std::string hex_encode(absl::string_view str) {
|
||||
return hex_encode(str.data(), str.size());
|
||||
}
|
||||
|
||||
std::string hex_encode(const char* source, size_t srclen) {
|
||||
@ -141,14 +142,14 @@ size_t hex_decode_with_delimiter(char* cbuffer,
|
||||
return bufpos;
|
||||
}
|
||||
|
||||
size_t hex_decode(char* buffer, size_t buflen, const std::string& source) {
|
||||
size_t hex_decode(char* buffer, size_t buflen, absl::string_view source) {
|
||||
return hex_decode_with_delimiter(buffer, buflen, source, 0);
|
||||
}
|
||||
size_t hex_decode_with_delimiter(char* buffer,
|
||||
size_t buflen,
|
||||
const std::string& source,
|
||||
absl::string_view source,
|
||||
char delimiter) {
|
||||
return hex_decode_with_delimiter(buffer, buflen, source.c_str(),
|
||||
return hex_decode_with_delimiter(buffer, buflen, source.data(),
|
||||
source.length(), delimiter);
|
||||
}
|
||||
|
||||
@ -177,7 +178,7 @@ bool tokenize_first(absl::string_view source,
|
||||
std::string* rest) {
|
||||
// Find the first delimiter
|
||||
size_t left_pos = source.find(delimiter);
|
||||
if (left_pos == std::string::npos) {
|
||||
if (left_pos == absl::string_view::npos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -245,8 +246,9 @@ std::string ToString(const bool b) {
|
||||
std::string ToString(const char* const s) {
|
||||
return std::string(s);
|
||||
}
|
||||
std::string ToString(const std::string s) {
|
||||
return s;
|
||||
|
||||
std::string ToString(absl::string_view s) {
|
||||
return std::string(s);
|
||||
}
|
||||
|
||||
std::string ToString(const short s) {
|
||||
|
||||
Reference in New Issue
Block a user