[Lldb-commits] [lldb] r369880 - [lldb][NFC] Add ProcessInfo::GetNameAsStringRef to simplify some code
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 26 01:22:53 PDT 2019
Author: teemperor
Date: Mon Aug 26 01:22:52 2019
New Revision: 369880
URL: http://llvm.org/viewvc/llvm-project?rev=369880&view=rev
Log:
[lldb][NFC] Add ProcessInfo::GetNameAsStringRef to simplify some code
Modified:
lldb/trunk/include/lldb/Utility/ProcessInfo.h
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/source/Utility/ProcessInfo.cpp
Modified: lldb/trunk/include/lldb/Utility/ProcessInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ProcessInfo.h?rev=369880&r1=369879&r2=369880&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/ProcessInfo.h (original)
+++ lldb/trunk/include/lldb/Utility/ProcessInfo.h Mon Aug 26 01:22:52 2019
@@ -38,7 +38,7 @@ public:
const char *GetName() const;
- size_t GetNameLength() const;
+ llvm::StringRef GetNameAsStringRef() const;
FileSpec &GetExecutableFile() { return m_executable; }
@@ -165,12 +165,8 @@ public:
void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); }
- const char *GetProcessNameAtIndex(size_t idx) {
- return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr);
- }
-
- size_t GetProcessNameLengthAtIndex(size_t idx) {
- return ((idx < m_infos.size()) ? m_infos[idx].GetNameLength() : 0);
+ llvm::StringRef GetProcessNameAtIndex(size_t idx) {
+ return ((idx < m_infos.size()) ? m_infos[idx].GetNameAsStringRef() : "");
}
lldb::pid_t GetProcessIDAtIndex(size_t idx) {
Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=369880&r1=369879&r2=369880&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Mon Aug 26 01:22:52 2019
@@ -1467,9 +1467,7 @@ public:
return;
for (uint32_t i = 0; i < num_matches; ++i) {
- request.AddCompletion(
- llvm::StringRef(process_infos.GetProcessNameAtIndex(i),
- process_infos.GetProcessNameLengthAtIndex(i)));
+ request.AddCompletion(process_infos.GetProcessNameAtIndex(i));
}
return;
}
Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=369880&r1=369879&r2=369880&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Mon Aug 26 01:22:52 2019
@@ -353,9 +353,7 @@ public:
if (num_matches == 0)
return;
for (size_t i = 0; i < num_matches; ++i) {
- request.AddCompletion(
- llvm::StringRef(process_infos.GetProcessNameAtIndex(i),
- process_infos.GetProcessNameLengthAtIndex(i)));
+ request.AddCompletion(process_infos.GetProcessNameAtIndex(i));
}
}
Modified: lldb/trunk/source/Utility/ProcessInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ProcessInfo.cpp?rev=369880&r1=369879&r2=369880&view=diff
==============================================================================
--- lldb/trunk/source/Utility/ProcessInfo.cpp (original)
+++ lldb/trunk/source/Utility/ProcessInfo.cpp Mon Aug 26 01:22:52 2019
@@ -42,8 +42,8 @@ const char *ProcessInfo::GetName() const
return m_executable.GetFilename().GetCString();
}
-size_t ProcessInfo::GetNameLength() const {
- return m_executable.GetFilename().GetLength();
+llvm::StringRef ProcessInfo::GetNameAsStringRef() const {
+ return m_executable.GetFilename().GetStringRef();
}
void ProcessInfo::Dump(Stream &s, Platform *platform) const {
More information about the lldb-commits
mailing list