[wpiutil] Replace LLVM StringMap impl with std::map

As string_view operations on std::map<std::string> won't be integrated
until C++26, placeholder implementations are used which are less efficient
in a couple of situations (e.g. insert with hint).
This commit is contained in:
Peter Johnson
2024-10-23 21:33:12 -07:00
parent 5f3cf517d3
commit f620141e0d
34 changed files with 944 additions and 2031 deletions

View File

@@ -49,7 +49,7 @@ class SendableChooser : public SendableChooserBase {
}
public:
using CopyType = decltype(_unwrap_smart_ptr(m_choices.lookup("")));
using CopyType = decltype(_unwrap_smart_ptr(m_choices.find("")->second));
SendableChooser() = default;
~SendableChooser() override = default;
@@ -105,7 +105,11 @@ class SendableChooser : public SendableChooserBase {
if (selected.empty()) {
return CopyType{};
} else {
return _unwrap_smart_ptr(m_choices.lookup(selected));
auto it = m_choices.find(selected);
if (it == m_choices.end()) {
return CopyType{};
}
return _unwrap_smart_ptr(it->second);
}
}
@@ -128,13 +132,8 @@ class SendableChooser : public SendableChooserBase {
[=, this] {
std::vector<std::string> keys;
for (const auto& choice : m_choices) {
keys.emplace_back(choice.first());
keys.emplace_back(choice.first);
}
// Unlike std::map, wpi::StringMap elements
// are not sorted
std::sort(keys.begin(), keys.end());
return keys;
},
nullptr);