summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility/StringList.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-07-31 03:26:10 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-07-31 03:26:10 +0000
commit175f0930907c56a80e0500cd201910c36222e788 (patch)
treedc3e71279bcd2a9f9e6c7d32e21916ecd04783e8 /lldb/source/Utility/StringList.cpp
parente825b834ecbd322db137ae8b69b6450282846ee8 (diff)
downloadbcm5719-llvm-175f0930907c56a80e0500cd201910c36222e788.tar.gz
bcm5719-llvm-175f0930907c56a80e0500cd201910c36222e788.zip
[StringList] Change LongestCommonPrefix API
When investigating a completion bug I got confused by the API. LongestCommonPrefix finds the longest common prefix of the strings in the string list. Instead of returning that string through an output argument, just return it by value. llvm-svn: 367384
Diffstat (limited to 'lldb/source/Utility/StringList.cpp')
-rw-r--r--lldb/source/Utility/StringList.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/lldb/source/Utility/StringList.cpp b/lldb/source/Utility/StringList.cpp
index fb0d9be8797..03249e00ccc 100644
--- a/lldb/source/Utility/StringList.cpp
+++ b/lldb/source/Utility/StringList.cpp
@@ -100,10 +100,9 @@ void StringList::Join(const char *separator, Stream &strm) {
void StringList::Clear() { m_strings.clear(); }
-void StringList::LongestCommonPrefix(std::string &common_prefix) {
- common_prefix.clear();
+std::string StringList::LongestCommonPrefix() {
if (m_strings.empty())
- return;
+ return {};
auto args = llvm::makeArrayRef(m_strings);
llvm::StringRef prefix = args.front();
@@ -115,7 +114,7 @@ void StringList::LongestCommonPrefix(std::string &common_prefix) {
}
prefix = prefix.take_front(count);
}
- common_prefix = prefix;
+ return prefix.str();
}
void StringList::InsertStringAtIndex(size_t idx, const char *str) {
OpenPOWER on IntegriCloud