Change container type for several uses of std::map/std::set
This commit is contained in:
@@ -79,7 +79,7 @@ int GetBridgeHeight(TileIndex t)
|
||||
return h + 1 + ApplyFoundationToSlope(f, tileh);
|
||||
}
|
||||
|
||||
std::unordered_map<TileIndex, LongBridgeSignalStorage> _long_bridge_signal_sim_map;
|
||||
robin_hood::unordered_flat_map<TileIndex, LongBridgeSignalStorage> _long_bridge_signal_sim_map;
|
||||
|
||||
SignalState GetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16_t signal)
|
||||
{
|
||||
|
@@ -15,15 +15,21 @@
|
||||
#include "signal_type.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "3rdparty/cpp-btree/btree_set.h"
|
||||
#include "3rdparty/robin_hood/robin_hood.h"
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
struct LongBridgeSignalStorage {
|
||||
std::vector<uint64_t> signal_red_bits;
|
||||
|
||||
LongBridgeSignalStorage() = default;
|
||||
LongBridgeSignalStorage(const LongBridgeSignalStorage &other) = delete;
|
||||
LongBridgeSignalStorage(LongBridgeSignalStorage &&other) = default;
|
||||
LongBridgeSignalStorage& operator=(const LongBridgeSignalStorage &other) = delete;
|
||||
LongBridgeSignalStorage& operator=(LongBridgeSignalStorage &&other) = default;
|
||||
};
|
||||
|
||||
extern std::unordered_map<TileIndex, LongBridgeSignalStorage> _long_bridge_signal_sim_map;
|
||||
extern robin_hood::unordered_flat_map<TileIndex, LongBridgeSignalStorage> _long_bridge_signal_sim_map;
|
||||
|
||||
extern btree::btree_set<uint32_t> _bridge_signal_style_map;
|
||||
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include "gfx_func.h"
|
||||
#include "core/math_func.hpp"
|
||||
|
||||
#include "3rdparty/cpp-btree/btree_map.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <stack>
|
||||
@@ -85,7 +87,7 @@ public:
|
||||
};
|
||||
|
||||
/** Mapping from index to font. The pointer is owned by FontColourMap. */
|
||||
using FontMap = std::map<int, Font *>;
|
||||
using FontMap = btree::btree_map<int, Font *>;
|
||||
|
||||
/**
|
||||
* Interface to glue fallback and normal layouter into one.
|
||||
@@ -173,7 +175,7 @@ private:
|
||||
|
||||
static LineCacheItem &GetCachedParagraphLayout(std::string_view str, const FontState &state);
|
||||
|
||||
using FontColourMap = std::map<TextColour, std::unique_ptr<Font>>;
|
||||
using FontColourMap = btree::btree_map<TextColour, std::unique_ptr<Font>>;
|
||||
static FontColourMap fonts[FS_END];
|
||||
public:
|
||||
static Font *GetFont(FontSize size, TextColour colour);
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "zoom_func.h"
|
||||
#include "unit_conversion.h"
|
||||
#include "core/math_func.hpp"
|
||||
#include "station_base.h"
|
||||
|
||||
#include "widgets/graph_widget.h"
|
||||
|
||||
@@ -31,7 +32,6 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "safeguards.h"
|
||||
#include "station_base.h"
|
||||
|
||||
/* Bitmasks of company and cargo indices that shouldn't be drawn. */
|
||||
static CompanyMask _legend_excluded_companies;
|
||||
|
@@ -37,7 +37,8 @@
|
||||
|
||||
#include "table/sprites.h"
|
||||
|
||||
#include <map>
|
||||
#include "3rdparty/robin_hood/robin_hood.h"
|
||||
|
||||
#include <numeric>
|
||||
#include "safeguards.h"
|
||||
|
||||
@@ -595,7 +596,7 @@ void ShowNewGRFTextfileWindow(TextfileType file_type, const GRFConfig *c)
|
||||
new NewGRFTextfileWindow(file_type, c);
|
||||
}
|
||||
|
||||
typedef std::map<uint32_t, const GRFConfig *> GrfIdMap; ///< Map of grfid to the grf config.
|
||||
typedef robin_hood::unordered_flat_map<uint32_t, const GRFConfig *> GrfIdMap; ///< Map of grfid to the grf config.
|
||||
|
||||
/**
|
||||
* Add all grf configs from \a c into the map.
|
||||
@@ -605,8 +606,7 @@ typedef std::map<uint32_t, const GRFConfig *> GrfIdMap; ///< Map of grfid to the
|
||||
static void FillGrfidMap(const GRFConfig *c, GrfIdMap *grfid_map)
|
||||
{
|
||||
while (c != nullptr) {
|
||||
std::pair<uint32_t, const GRFConfig *> p(c->ident.grfid, c);
|
||||
grfid_map->insert(p);
|
||||
grfid_map->insert({c->ident.grfid, c});
|
||||
c = c->next;
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "core/arena_alloc.hpp"
|
||||
|
||||
#include "3rdparty/cpp-btree/btree_map.h"
|
||||
#include "3rdparty/robin_hood/robin_hood.h"
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
|
||||
@@ -68,11 +69,11 @@ public:
|
||||
std::vector<const SpriteGroup *> spritegroups;
|
||||
|
||||
/* VarAction2 temporary storage variable tracking */
|
||||
btree::btree_map<const SpriteGroup *, VarAction2GroupVariableTracking *> group_temp_store_variable_tracking;
|
||||
robin_hood::unordered_flat_map<const SpriteGroup *, VarAction2GroupVariableTracking *> group_temp_store_variable_tracking;
|
||||
UniformArenaAllocator<sizeof(VarAction2GroupVariableTracking), 1024> group_temp_store_variable_tracking_storage;
|
||||
btree::btree_map<const SpriteGroup *, VarAction2ProcedureAnnotation *> procedure_annotations;
|
||||
robin_hood::unordered_flat_map<const SpriteGroup *, VarAction2ProcedureAnnotation *> procedure_annotations;
|
||||
UniformArenaAllocator<sizeof(VarAction2ProcedureAnnotation), 1024> procedure_annotations_storage;
|
||||
btree::btree_map<const DeterministicSpriteGroup *, std::vector<DeterministicSpriteGroupAdjust> *> inlinable_adjust_groups;
|
||||
robin_hood::unordered_flat_map<const DeterministicSpriteGroup *, std::vector<DeterministicSpriteGroupAdjust> *> inlinable_adjust_groups;
|
||||
UniformArenaAllocator<sizeof(std::vector<DeterministicSpriteGroupAdjust>), 1024> inlinable_adjust_groups_storage;
|
||||
std::vector<DeterministicSpriteGroup *> dead_store_elimination_candidates;
|
||||
|
||||
|
@@ -28,8 +28,8 @@ INSTANTIATE_POOL_METHODS(SpriteGroup)
|
||||
|
||||
TemporaryStorageArray<int32_t, 0x110> _temp_store;
|
||||
|
||||
std::map<const DeterministicSpriteGroup *, DeterministicSpriteGroupShadowCopy> _deterministic_sg_shadows;
|
||||
std::map<const RandomizedSpriteGroup *, RandomizedSpriteGroupShadowCopy> _randomized_sg_shadows;
|
||||
robin_hood::unordered_node_map<const DeterministicSpriteGroup *, DeterministicSpriteGroupShadowCopy> _deterministic_sg_shadows;
|
||||
robin_hood::unordered_flat_map<const RandomizedSpriteGroup *, RandomizedSpriteGroupShadowCopy> _randomized_sg_shadows;
|
||||
bool _grfs_loaded_with_sg_shadow_enable = false;
|
||||
|
||||
GrfSpecFeature GetGrfSpecFeatureForParentScope(GrfSpecFeature feature)
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include "newgrf_storage.h"
|
||||
#include "newgrf_commons.h"
|
||||
|
||||
#include "3rdparty/cpp-btree/btree_set.h"
|
||||
#include "3rdparty/robin_hood/robin_hood.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@@ -541,8 +541,8 @@ protected:
|
||||
const SpriteGroup *Resolve(ResolverObject &object) const override;
|
||||
};
|
||||
|
||||
extern std::map<const DeterministicSpriteGroup *, DeterministicSpriteGroupShadowCopy> _deterministic_sg_shadows;
|
||||
extern std::map<const RandomizedSpriteGroup *, RandomizedSpriteGroupShadowCopy> _randomized_sg_shadows;
|
||||
extern robin_hood::unordered_node_map<const DeterministicSpriteGroup *, DeterministicSpriteGroupShadowCopy> _deterministic_sg_shadows;
|
||||
extern robin_hood::unordered_flat_map<const RandomizedSpriteGroup *, RandomizedSpriteGroupShadowCopy> _randomized_sg_shadows;
|
||||
extern bool _grfs_loaded_with_sg_shadow_enable;
|
||||
|
||||
/* This contains a callback result. A failed callback has a value of
|
||||
@@ -779,7 +779,7 @@ private:
|
||||
|
||||
const SpriteGroup *top_default_group = nullptr;
|
||||
const SpriteGroup *top_graphics_group = nullptr;
|
||||
btree::btree_set<const DeterministicSpriteGroup *> seen_dsgs;
|
||||
robin_hood::unordered_flat_set<const DeterministicSpriteGroup *> seen_dsgs;
|
||||
|
||||
enum SpriteGroupDumperFlags {
|
||||
SGDF_DEFAULT = 1 << 0,
|
||||
|
@@ -12,7 +12,7 @@
|
||||
|
||||
#include "script_object.hpp"
|
||||
#include "script_companymode.hpp"
|
||||
#include <map>
|
||||
#include "../../3rdparty/robin_hood/robin_hood.h"
|
||||
#include <optional>
|
||||
|
||||
/**
|
||||
@@ -221,8 +221,8 @@ public:
|
||||
static void RegisterErrorMapString(ScriptErrorType ai_error_msg, const char *message);
|
||||
|
||||
private:
|
||||
typedef std::map<StringID, ScriptErrorType> ScriptErrorMap; ///< The type for mapping between error (internal OpenTTD) StringID to the script error type.
|
||||
typedef std::map<ScriptErrorType, const char *> ScriptErrorMapString; ///< The type for mapping between error type and textual representation.
|
||||
typedef robin_hood::unordered_flat_map<StringID, ScriptErrorType> ScriptErrorMap; ///< The type for mapping between error (internal OpenTTD) StringID to the script error type.
|
||||
typedef robin_hood::unordered_flat_map<ScriptErrorType, const char *> ScriptErrorMapString; ///< The type for mapping between error type and textual representation.
|
||||
|
||||
static ScriptErrorMap error_map; ///< The mapping between error (internal OpenTTD) StringID to the script error type.
|
||||
static ScriptErrorMapString error_map_string; ///< The mapping between error type and textual representation.
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "../economy_base.h"
|
||||
#include "../event_logs.h"
|
||||
#include "../3rdparty/cpp-btree/btree_map.h"
|
||||
#include "../3rdparty/robin_hood/robin_hood.h"
|
||||
#include "../core/format.hpp"
|
||||
|
||||
#include "saveload.h"
|
||||
@@ -296,7 +297,7 @@ void AfterLoadVehicles(bool part_of_load)
|
||||
* a) both next_shared and previous_shared are not set for pre 5,2 games
|
||||
* b) both next_shared and previous_shared are set for later games
|
||||
*/
|
||||
std::map<Order*, OrderList*> mapping;
|
||||
robin_hood::unordered_flat_map<Order*, OrderList*> mapping;
|
||||
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
si_v = v;
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#define TIMER_MANAGER_H
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include <set>
|
||||
#include "../3rdparty/cpp-btree/btree_set.h"
|
||||
|
||||
template <typename TTimerType>
|
||||
class BaseTimer;
|
||||
@@ -112,9 +112,9 @@ private:
|
||||
};
|
||||
|
||||
/** Singleton list, to store all the active timers. */
|
||||
static std::set<BaseTimer<TTimerType> *, base_timer_sorter> &GetTimers()
|
||||
static btree::btree_set<BaseTimer<TTimerType> *, base_timer_sorter> &GetTimers()
|
||||
{
|
||||
static std::set<BaseTimer<TTimerType> *, base_timer_sorter> timers;
|
||||
static btree::btree_set<BaseTimer<TTimerType> *, base_timer_sorter> timers;
|
||||
return timers;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user