summaryrefslogtreecommitdiff
path: root/src/mode.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-08-17 12:49:48 +0200
committerAttila Molnar <attilamolnar@hush.com>2016-08-17 12:49:48 +0200
commitb9e11915a976daaf790ebc763aff56e19fd49e0f (patch)
tree7c69dc9427a8a0470ff12f772846b956e747bf78 /src/mode.cpp
parentf9fd78c01623514a060c607534fc52cb73140200 (diff)
parentc7a26bc21629ddd4103dac1ff7f9acf45a2c4d35 (diff)
Merge insp20
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index b29eda828..3762dc52e 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -791,24 +791,33 @@ std::string ModeParser::GiveModeList(ModeType mt)
return type1 + "," + type2 + "," + type3 + "," + type4;
}
+struct PrefixModeSorter
+{
+ bool operator()(PrefixMode* lhs, PrefixMode* rhs)
+ {
+ return lhs->GetPrefixRank() < rhs->GetPrefixRank();
+ }
+};
+
std::string ModeParser::BuildPrefixes(bool lettersAndModes)
{
std::string mletters;
std::string mprefixes;
- insp::flat_map<int, std::pair<char, char> > prefixes;
+ std::vector<PrefixMode*> prefixes;
const PrefixModeList& list = GetPrefixModes();
for (PrefixModeList::const_iterator i = list.begin(); i != list.end(); ++i)
{
PrefixMode* pm = *i;
if (pm->GetPrefix())
- prefixes[pm->GetPrefixRank()] = std::make_pair(pm->GetPrefix(), pm->GetModeChar());
+ prefixes.push_back(pm);
}
- for (insp::flat_map<int, std::pair<char, char> >::reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); ++n)
+ std::sort(prefixes.begin(), prefixes.end(), PrefixModeSorter());
+ for (std::vector<PrefixMode*>::const_reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); ++n)
{
- mletters = mletters + n->second.first;
- mprefixes = mprefixes + n->second.second;
+ mletters += (*n)->GetPrefix();
+ mprefixes += (*n)->GetModeChar();
}
return lettersAndModes ? "(" + mprefixes + ")" + mletters : mletters;