[core] Replace SmallMap

Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
x7z4w
2025-11-24 17:34:56 +00:00
committed by Konstantin Pastbin
parent 969e1ef2da
commit 882dccb87d
25 changed files with 162 additions and 742 deletions

View File

@@ -28,7 +28,6 @@
#include "drape/utils/projection.hpp"
#include "base/logging.hpp"
#include "base/small_map.hpp"
#include "base/stl_helpers.hpp"
#include <algorithm>
@@ -37,6 +36,8 @@
#include <map>
#include <mutex>
#include "3party/skarupke/flat_hash_map.hpp"
namespace df
{
dp::Color ToDrapeColor(uint32_t src)
@@ -271,7 +272,7 @@ dp::Color GetRoadShieldColor(dp::Color const & baseColor, ftypes::RoadShield con
{
using ftypes::RoadShieldType;
static base::SmallMapBase<ftypes::RoadShieldType, df::ColorConstant> kColors = {
static ska::flat_hash_map<RoadShieldType, df::ColorConstant> const kColors = {
{RoadShieldType::Generic_White, kRoadShieldWhiteBackgroundColor},
{RoadShieldType::Generic_Green, kRoadShieldGreenBackgroundColor},
{RoadShieldType::Generic_Blue, kRoadShieldBlueBackgroundColor},
@@ -294,8 +295,9 @@ dp::Color GetRoadShieldColor(dp::Color const & baseColor, ftypes::RoadShield con
{RoadShieldType::Generic_Pill_Orange_Bordered, kRoadShieldOrangeBackgroundColor},
{RoadShieldType::UK_Highway, kRoadShieldGreenBackgroundColor}};
if (auto const * cl = kColors.Find(shield.m_type); cl)
return df::GetColorConstant(*cl);
auto const it = kColors.find(shield.m_type);
if (it != kColors.cend())
return df::GetColorConstant(it->second);
return baseColor;
}
@@ -304,7 +306,7 @@ dp::Color GetRoadShieldTextColor(dp::Color const & baseColor, ftypes::RoadShield
{
using ftypes::RoadShieldType;
static base::SmallMapBase<ftypes::RoadShieldType, df::ColorConstant> kColors = {
static ska::flat_hash_map<RoadShieldType, df::ColorConstant> const kColors = {
{RoadShieldType::Generic_White, kRoadShieldBlackTextColor},
{RoadShieldType::Generic_Green, kRoadShieldWhiteTextColor},
{RoadShieldType::Generic_Blue, kRoadShieldWhiteTextColor},
@@ -336,8 +338,9 @@ dp::Color GetRoadShieldTextColor(dp::Color const & baseColor, ftypes::RoadShield
{RoadShieldType::Hungary_Green, kRoadShieldWhiteTextColor},
{RoadShieldType::Hungary_Blue, kRoadShieldWhiteTextColor}};
if (auto const * cl = kColors.Find(shield.m_type); cl)
return df::GetColorConstant(*cl);
auto const it = kColors.find(shield.m_type);
if (it != kColors.cend())
return df::GetColorConstant(it->second);
return baseColor;
}