[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Fri May 3 10:57:09 PDT 2024
================
@@ -289,3 +290,19 @@ void StructuredData::Null::GetDescription(lldb_private::Stream &s) const {
void StructuredData::Generic::GetDescription(lldb_private::Stream &s) const {
s.Printf("%p", m_object);
}
+
+StructuredData::ArraySP StructuredData::Array::SplitString(llvm::StringRef s,
+ char separator,
+ int maxSplit,
+ bool keepEmpty) {
+ // Split the string into a small vector.
+ llvm::SmallVector<StringRef> small_vec;
+ s.split(small_vec, separator, maxSplit, keepEmpty);
+
+ // Copy the substrings from the small vector into the output array.
+ auto array_sp = std::make_shared<StructuredData::Array>();
+ for (auto substring : small_vec) {
+ array_sp->AddStringItem(std::move(substring));
----------------
bulbazord wrote:
nit: no need for the move, StringRefs are pretty cheap to copy
https://github.com/llvm/llvm-project/pull/90703
More information about the lldb-commits
mailing list