bulbazord created this revision. bulbazord added reviewers: JDevlieghere, mib, jingham. Herald added a project: All. bulbazord requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
Broadcasters don't need their names in the StringPool. It doesn't benefit from fast comparisons and doesn't benefit from uniqueness. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D152220 Files: lldb/include/lldb/Utility/Broadcaster.h lldb/source/API/SBBroadcaster.cpp lldb/source/Core/ThreadedCommunication.cpp lldb/source/Utility/Broadcaster.cpp lldb/source/Utility/Event.cpp lldb/source/Utility/Listener.cpp
Index: lldb/source/Utility/Listener.cpp =================================================================== --- lldb/source/Utility/Listener.cpp +++ lldb/source/Utility/Listener.cpp @@ -234,7 +234,7 @@ if (m_broadcaster_names) { bool found_source = false; - ConstString event_broadcaster_name = + const llvm::StringRef event_broadcaster_name = event_sp->GetBroadcaster()->GetBroadcasterName(); for (uint32_t i = 0; i < m_num_broadcaster_names; ++i) { if (m_broadcaster_names[i] == event_broadcaster_name) { Index: lldb/source/Utility/Event.cpp =================================================================== --- lldb/source/Utility/Event.cpp +++ lldb/source/Utility/Event.cpp @@ -58,13 +58,13 @@ s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x (%s), data = ", static_cast<const void *>(this), static_cast<void *>(broadcaster), - broadcaster->GetBroadcasterName().GetCString(), m_type, + broadcaster->GetBroadcasterName().c_str(), m_type, event_name.GetData()); else s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x, data = ", static_cast<const void *>(this), static_cast<void *>(broadcaster), - broadcaster->GetBroadcasterName().GetCString(), m_type); + broadcaster->GetBroadcasterName().c_str(), m_type); } else s->Printf("%p Event: broadcaster = NULL, type = 0x%8.8x, data = ", static_cast<const void *>(this), m_type); Index: lldb/source/Utility/Broadcaster.cpp =================================================================== --- lldb/source/Utility/Broadcaster.cpp +++ lldb/source/Utility/Broadcaster.cpp @@ -23,9 +23,9 @@ using namespace lldb; using namespace lldb_private; -Broadcaster::Broadcaster(BroadcasterManagerSP manager_sp, const char *name) +Broadcaster::Broadcaster(BroadcasterManagerSP manager_sp, llvm::StringRef name) : m_broadcaster_sp(std::make_shared<BroadcasterImpl>(*this)), - m_manager_sp(std::move(manager_sp)), m_broadcaster_name(name) { + m_manager_sp(std::move(manager_sp)), m_broadcaster_name(name.str()) { Log *log = GetLog(LLDBLog::Object); LLDB_LOG(log, "{0} Broadcaster::Broadcaster(\"{1}\")", static_cast<void *>(this), GetBroadcasterName()); Index: lldb/source/Core/ThreadedCommunication.cpp =================================================================== --- lldb/source/Core/ThreadedCommunication.cpp +++ lldb/source/Core/ThreadedCommunication.cpp @@ -57,7 +57,7 @@ ThreadedCommunication::~ThreadedCommunication() { LLDB_LOG(GetLog(LLDBLog::Object | LLDBLog::Communication), "{0} ThreadedCommunication::~ThreadedCommunication (name = {1})", - this, GetBroadcasterName().AsCString()); + this, GetBroadcasterName()); } void ThreadedCommunication::Clear() { Index: lldb/source/API/SBBroadcaster.cpp =================================================================== --- lldb/source/API/SBBroadcaster.cpp +++ lldb/source/API/SBBroadcaster.cpp @@ -92,7 +92,7 @@ LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) - return m_opaque_ptr->GetBroadcasterName().GetCString(); + return ConstString(m_opaque_ptr->GetBroadcasterName()).GetCString(); return nullptr; } Index: lldb/include/lldb/Utility/Broadcaster.h =================================================================== --- lldb/include/lldb/Utility/Broadcaster.h +++ lldb/include/lldb/Utility/Broadcaster.h @@ -149,10 +149,12 @@ public: /// Construct with a broadcaster with a name. /// + /// \param[in] manager_sp + /// A shared pointer to the BroadcasterManager that will manage this + /// broadcaster. /// \param[in] name - /// A NULL terminated C string that contains the name of the - /// broadcaster object. - Broadcaster(lldb::BroadcasterManagerSP manager_sp, const char *name); + /// A StringRef of the name that this broadcaster will have. + Broadcaster(lldb::BroadcasterManagerSP manager_sp, llvm::StringRef name); /// Destructor. /// @@ -213,11 +215,12 @@ return m_broadcaster_sp->AddListener(listener_sp, event_mask); } - /// Get the NULL terminated C string name of this Broadcaster object. + /// Get this broadcaster's name. /// /// \return - /// The NULL terminated C string name of this Broadcaster. - ConstString GetBroadcasterName() { return m_broadcaster_name; } + /// A reference to a constant std::string containing the name of the + /// broadcaster. + const std::string &GetBroadcasterName() { return m_broadcaster_name; } /// Get the event name(s) for one or more event bits. /// @@ -352,8 +355,8 @@ uint32_t AddListener(const lldb::ListenerSP &listener_sp, uint32_t event_mask); - const char *GetBroadcasterName() const { - return m_broadcaster.GetBroadcasterName().AsCString(); + llvm::StringRef GetBroadcasterName() const { + return m_broadcaster.GetBroadcasterName(); } Broadcaster *GetBroadcaster(); @@ -443,7 +446,7 @@ lldb::BroadcasterManagerSP m_manager_sp; /// The name of this broadcaster object. - const ConstString m_broadcaster_name; + const std::string m_broadcaster_name; Broadcaster(const Broadcaster &) = delete; const Broadcaster &operator=(const Broadcaster &) = delete;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits