mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use FlatSet when filtering and drawing badge names.
parent
5fd7344a6d
commit
7679b0bc46
|
@ -318,10 +318,7 @@ BadgeTextFilter::BadgeTextFilter(StringFilter &filter, GrfSpecFeature feature)
|
|||
filter.AddLine(GetString(badge.name));
|
||||
if (!filter.GetState()) continue;
|
||||
|
||||
auto it = std::ranges::lower_bound(this->badges, badge.index);
|
||||
if (it != std::end(this->badges) && *it == badge.index) continue;
|
||||
|
||||
this->badges.insert(it, badge.index);
|
||||
this->badges.insert(badge.index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#ifndef NEWGRF_BADGE_H
|
||||
#define NEWGRF_BADGE_H
|
||||
|
||||
#include "core/flatset_type.hpp"
|
||||
#include "newgrf.h"
|
||||
#include "newgrf_badge_type.h"
|
||||
#include "newgrf_commons.h"
|
||||
|
@ -65,7 +66,7 @@ public:
|
|||
bool Filter(std::span<const BadgeID> badges) const;
|
||||
|
||||
private:
|
||||
std::vector<BadgeID> badges{};
|
||||
FlatSet<BadgeID> badges{};
|
||||
};
|
||||
|
||||
#endif /* NEWGRF_BADGE_H */
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "core/flatset_type.hpp"
|
||||
#include "dropdown_type.h"
|
||||
#include "newgrf.h"
|
||||
#include "newgrf_badge.h"
|
||||
|
@ -120,7 +121,7 @@ int DrawBadgeNameList(Rect r, std::span<const BadgeID> badges, GrfSpecFeature)
|
|||
{
|
||||
if (badges.empty()) return r.top;
|
||||
|
||||
std::set<BadgeClassID> class_indexes;
|
||||
FlatSet<BadgeClassID> class_indexes;
|
||||
for (const BadgeID &index : badges) class_indexes.insert(GetBadge(index)->class_index);
|
||||
|
||||
std::string_view list_separator = GetListSeparator();
|
||||
|
|
Loading…
Reference in New Issue