[Lldb-commits] [lldb] r369242 - [lldb][NFC] Remove StringList::AutoComplete
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 19 01:15:46 PDT 2019
Author: teemperor
Date: Mon Aug 19 01:15:46 2019
New Revision: 369242
URL: http://llvm.org/viewvc/llvm-project?rev=369242&view=rev
Log:
[lldb][NFC] Remove StringList::AutoComplete
We don't need this very specific function in StringList that
we only call once in LLDB.
Modified:
lldb/trunk/include/lldb/Utility/StringList.h
lldb/trunk/source/Commands/CommandCompletions.cpp
lldb/trunk/source/Utility/StringList.cpp
Modified: lldb/trunk/include/lldb/Utility/StringList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/StringList.h?rev=369242&r1=369241&r2=369242&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/StringList.h (original)
+++ lldb/trunk/include/lldb/Utility/StringList.h Mon Aug 19 01:15:46 2019
@@ -107,14 +107,6 @@ public:
// Copy assignment for a vector of strings
StringList &operator=(const std::vector<std::string> &rhs);
- // This string list contains a list of valid auto completion strings, and the
- // "s" is passed in. "matches" is filled in with zero or more string values
- // that start with "s", and the first string to exactly match one of the
- // string values in this collection, will have "exact_matches_idx" filled in
- // to match the index, or "exact_matches_idx" will have SIZE_MAX
- size_t AutoComplete(llvm::StringRef s, StringList &matches,
- size_t &exact_matches_idx) const;
-
// Dump the StringList to the given lldb_private::Log, `log`, one item per
// line. If given, `name` will be used to identify the start and end of the
// list in the output.
Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=369242&r1=369241&r2=369242&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
+++ lldb/trunk/source/Commands/CommandCompletions.cpp Mon Aug 19 01:15:46 2019
@@ -309,12 +309,18 @@ int CommandCompletions::SettingsNames(Co
}
}
- size_t exact_matches_idx = SIZE_MAX;
- StringList matches;
- g_property_names.AutoComplete(request.GetCursorArgumentPrefix(), matches,
- exact_matches_idx);
- request.SetWordComplete(exact_matches_idx != SIZE_MAX);
- request.AddCompletions(matches);
+ bool exact_match = false;
+
+ for (const std::string &s : g_property_names) {
+ if (llvm::StringRef(s).startswith(request.GetCursorArgumentPrefix())) {
+ if (request.GetCursorArgumentPrefix() == s)
+ exact_match = true;
+ request.AddCompletion(s);
+ }
+ }
+
+ request.SetWordComplete(exact_match);
+
return request.GetNumberOfMatches();
}
Modified: lldb/trunk/source/Utility/StringList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringList.cpp?rev=369242&r1=369241&r2=369242&view=diff
==============================================================================
--- lldb/trunk/source/Utility/StringList.cpp (original)
+++ lldb/trunk/source/Utility/StringList.cpp Mon Aug 19 01:15:46 2019
@@ -223,29 +223,6 @@ StringList &StringList::operator=(const
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;
More information about the lldb-commits
mailing list