mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-15 14:50:39 +01:00
Switch to absl::string_view in field_trial::FindFullName()
Bug: webrtc:13579 Change-Id: Iaaea42957afb4af66ad5eea6447e75dddc13b5ea Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256263 Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Ali Tofigh <alito@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36288}
This commit is contained in:
parent
2b168062d6
commit
04c881683d
2 changed files with 10 additions and 8 deletions
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
|
|
||||||
// Field trials allow webrtc clients (such as Chrome) to turn on feature code
|
// Field trials allow webrtc clients (such as Chrome) to turn on feature code
|
||||||
// in binaries out in the field and gather information with that.
|
// in binaries out in the field and gather information with that.
|
||||||
//
|
//
|
||||||
|
@ -61,7 +63,7 @@ namespace field_trial {
|
||||||
// if the trial does not exists.
|
// if the trial does not exists.
|
||||||
//
|
//
|
||||||
// Note: To keep things tidy append all the trial names with WebRTC.
|
// Note: To keep things tidy append all the trial names with WebRTC.
|
||||||
std::string FindFullName(const std::string& name);
|
std::string FindFullName(absl::string_view name);
|
||||||
|
|
||||||
// Convenience method, returns true iff FindFullName(name) return a string that
|
// Convenience method, returns true iff FindFullName(name) return a string that
|
||||||
// starts with "Enabled".
|
// starts with "Enabled".
|
||||||
|
|
|
@ -102,11 +102,11 @@ std::string MergeFieldTrialsStrings(const char* first, const char* second) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT
|
#ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT
|
||||||
std::string FindFullName(const std::string& name) {
|
std::string FindFullName(absl::string_view name) {
|
||||||
if (trials_init_string == NULL)
|
if (trials_init_string == NULL)
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
std::string trials_string(trials_init_string);
|
absl::string_view trials_string(trials_init_string);
|
||||||
if (trials_string.empty())
|
if (trials_string.empty())
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
|
@ -122,14 +122,14 @@ std::string FindFullName(const std::string& name) {
|
||||||
if (field_value_end == trials_string.npos ||
|
if (field_value_end == trials_string.npos ||
|
||||||
field_value_end == field_name_end + 1)
|
field_value_end == field_name_end + 1)
|
||||||
break;
|
break;
|
||||||
std::string field_name(trials_string, next_item,
|
absl::string_view field_name =
|
||||||
field_name_end - next_item);
|
trials_string.substr(next_item, field_name_end - next_item);
|
||||||
std::string field_value(trials_string, field_name_end + 1,
|
absl::string_view field_value = trials_string.substr(
|
||||||
field_value_end - field_name_end - 1);
|
field_name_end + 1, field_value_end - field_name_end - 1);
|
||||||
next_item = field_value_end + 1;
|
next_item = field_value_end + 1;
|
||||||
|
|
||||||
if (name == field_name)
|
if (name == field_name)
|
||||||
return field_value;
|
return std::string(field_value);
|
||||||
}
|
}
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue