================
@@ -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
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits