bulbazord created this revision. bulbazord added reviewers: JDevlieghere, jingham, mib, jasonmolenda. Herald added a project: All. bulbazord requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
The strings "DarwinLog" and "log" probably do not need to be in the ConstString StringPool. We still create ConstStrings from them in some places (for now) but that's because we don't have an implicit constructor to convert a StringRef to a ConstString. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D151599 Files: lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
Index: lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp =================================================================== --- lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -162,13 +162,13 @@ // used to format message text }; -static ConstString GetDarwinLogTypeName() { - static const ConstString s_key_name("DarwinLog"); +static llvm::StringRef GetDarwinLogTypeName() { + static constexpr llvm::StringLiteral s_key_name("DarwinLog"); return s_key_name; } -static ConstString GetLogEventType() { - static const ConstString s_event_type("log"); +static llvm::StringRef GetLogEventType() { + static constexpr llvm::StringLiteral s_event_type("log"); return s_event_type; } @@ -799,8 +799,8 @@ } // Get the plugin for the process. - auto plugin_sp = - process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName()); + auto plugin_sp = process_sp->GetStructuredDataPlugin( + ConstString(GetDarwinLogTypeName())); if (!plugin_sp || (plugin_sp->GetPluginName() != StructuredDataDarwinLog::GetStaticPluginName())) { result.AppendError("failed to get StructuredDataPlugin for " @@ -822,8 +822,8 @@ // Send configuration to the feature by way of the process. Construct the // options we will use. auto config_sp = m_options_sp->BuildConfigurationData(m_enable); - const Status error = - process_sp->ConfigureStructuredData(GetDarwinLogTypeName(), config_sp); + const Status error = process_sp->ConfigureStructuredData( + ConstString(GetDarwinLogTypeName()), config_sp); // Report results. if (!error.Success()) { @@ -871,8 +871,8 @@ stream.PutCString("Enabled: not applicable " "(requires process)\n"); } else { - auto plugin_sp = - process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName()); + auto plugin_sp = process_sp->GetStructuredDataPlugin( + ConstString(GetDarwinLogTypeName())); stream.Printf("Availability: %s\n", plugin_sp ? "available" : "unavailable"); llvm::StringRef plugin_name = StructuredDataDarwinLog::GetStaticPluginName(); @@ -1089,7 +1089,7 @@ LLDB_LOGF(log, "StructuredDataDarwinLog::%s() StructuredData type " "expected to be %s but was %s, ignoring", - __FUNCTION__, GetDarwinLogTypeName().AsCString(), + __FUNCTION__, GetDarwinLogTypeName().str().c_str(), type_name.AsCString()); return; } @@ -1142,7 +1142,7 @@ } // Validate this is really a message for our plugin. - ConstString type_name; + llvm::StringRef type_name; if (!dictionary->GetValueForKeyAsString("type", type_name)) { SetErrorWithJSON(error, "Structured data doesn't contain mandatory " "type field", @@ -1490,12 +1490,13 @@ LLDB_LOGF(log, "StructuredDataDarwinLog::%s() call is for process uid %d", __FUNCTION__, process_sp->GetUniqueID()); - auto plugin_sp = process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName()); + auto plugin_sp = + process_sp->GetStructuredDataPlugin(ConstString(GetDarwinLogTypeName())); if (!plugin_sp) { LLDB_LOGF(log, "StructuredDataDarwinLog::%s() warning: no plugin for " "feature %s in process uid %u", - __FUNCTION__, GetDarwinLogTypeName().AsCString(), + __FUNCTION__, GetDarwinLogTypeName().str().c_str(), process_sp->GetUniqueID()); return false; } @@ -1736,7 +1737,7 @@ size_t StructuredDataDarwinLog::HandleDisplayOfEvent( const StructuredData::Dictionary &event, Stream &stream) { // Check the type of the event. - ConstString event_type; + llvm::StringRef event_type; if (!event.GetValueForKeyAsString("type", event_type)) { // Hmm, we expected to get events that describe what they are. Continue // anyway. @@ -1836,8 +1837,8 @@ // We can run it directly. // Send configuration to the feature by way of the process. - const Status error = - process_sp->ConfigureStructuredData(GetDarwinLogTypeName(), config_sp); + const Status error = process_sp->ConfigureStructuredData( + ConstString(GetDarwinLogTypeName()), config_sp); // Report results. if (!error.Success()) {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits