Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Unified Diff: base/trace_event/trace_event_etw_export_win.cc

Issue 2777203004: Avoid calling strlen() where possible in base/trace_config (Closed)
Patch Set: Keep DCHECKs. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/trace_event/trace_event_etw_export_win.cc
diff --git a/base/trace_event/trace_event_etw_export_win.cc b/base/trace_event/trace_event_etw_export_win.cc
index 06a6b9574a8b55eca887a2786bc1820d4432b8bb..e97ab56be6e03233596bc0ac28e007350b3821a3 100644
--- a/base/trace_event/trace_event_etw_export_win.cc
+++ b/base/trace_event/trace_event_etw_export_win.cc
@@ -348,8 +348,8 @@ void TraceEventETWExport::AddCompleteEndEvent(const char* name) {
// static
bool TraceEventETWExport::IsCategoryGroupEnabled(
- const char* category_group_name) {
- DCHECK(category_group_name);
+ StringPiece category_group_name) {
+ DCHECK(!category_group_name.empty());
auto* instance = GetInstance();
if (instance == nullptr)
return false;
@@ -357,12 +357,11 @@ bool TraceEventETWExport::IsCategoryGroupEnabled(
if (!instance->IsETWExportEnabled())
return false;
- CStringTokenizer category_group_tokens(
- category_group_name, category_group_name + strlen(category_group_name),
- ",");
+ CStringTokenizer category_group_tokens(category_group_name.begin(),
+ category_group_name.end(), ",");
while (category_group_tokens.GetNext()) {
- std::string category_group_token = category_group_tokens.token();
- if (instance->IsCategoryEnabled(category_group_token.c_str())) {
+ StringPiece category_group_token = category_group_tokens.token_piece();
+ if (instance->IsCategoryEnabled(category_group_token)) {
return true;
}
}
@@ -406,7 +405,7 @@ bool TraceEventETWExport::UpdateEnabledCategories() {
return true;
}
-bool TraceEventETWExport::IsCategoryEnabled(const char* category_name) const {
+bool TraceEventETWExport::IsCategoryEnabled(StringPiece category_name) const {
DCHECK_EQ(kNumberOfCategories, categories_status_.size());
// Try to find the category and return its status if found
auto it = categories_status_.find(category_name);
@@ -415,7 +414,7 @@ bool TraceEventETWExport::IsCategoryEnabled(const char* category_name) const {
// Otherwise return the corresponding default status by first checking if the
// category is disabled by default.
- if (StringPiece(category_name).starts_with("disabled-by-default")) {
+ if (category_name.starts_with("disabled-by-default")) {
DCHECK(categories_status_.find(kDisabledOtherEventsGroupName) !=
categories_status_.end());
return categories_status_.find(kDisabledOtherEventsGroupName)->second;
« no previous file with comments | « base/trace_event/trace_event_etw_export_win.h ('k') | chrome/browser/chromeos/arc/tracing/arc_tracing_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698