aboutsummaryrefslogtreecommitdiffstats
path: root/source/Utility/StringList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Utility/StringList.cpp')
-rw-r--r--source/Utility/StringList.cpp36
1 files changed, 5 insertions, 31 deletions
diff --git a/source/Utility/StringList.cpp b/source/Utility/StringList.cpp
index fb0d9be8797d..5e06b6b69fc0 100644
--- a/source/Utility/StringList.cpp
+++ b/source/Utility/StringList.cpp
@@ -61,10 +61,8 @@ void StringList::AppendList(const char **strv, int strc) {
}
void StringList::AppendList(StringList strings) {
- size_t len = strings.GetSize();
-
- for (size_t i = 0; i < len; ++i)
- m_strings.push_back(strings.GetStringAtIndex(i));
+ m_strings.reserve(m_strings.size() + strings.GetSize());
+ m_strings.insert(m_strings.end(), strings.begin(), strings.end());
}
size_t StringList::GetSize() const { return m_strings.size(); }
@@ -100,10 +98,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 +112,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) {
@@ -226,29 +223,6 @@ StringList &StringList::operator=(const std::vector<std::string> &rhs) {
return *this;
}
-size_t StringList::AutoComplete(llvm::StringRef s, StringList &matches,
- size_t &exact_idx) const {
- matches.Clear();
- exact_idx = SIZE_MAX;
- if (s.empty()) {
- // No string, so it matches everything
- matches = *this;
- return matches.GetSize();
- }
-
- const size_t s_len = s.size();
- const size_t num_strings = m_strings.size();
-
- for (size_t i = 0; i < num_strings; ++i) {
- if (m_strings[i].find(s) == 0) {
- if (exact_idx == SIZE_MAX && m_strings[i].size() == s_len)
- exact_idx = matches.GetSize();
- matches.AppendString(m_strings[i]);
- }
- }
- return matches.GetSize();
-}
-
void StringList::LogDump(Log *log, const char *name) {
if (!log)
return;