mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user