diff --git a/libs/base/geo_object_id.cpp b/libs/base/geo_object_id.cpp index 51227d0f2..65a4fd9ef 100644 --- a/libs/base/geo_object_id.cpp +++ b/libs/base/geo_object_id.cpp @@ -10,9 +10,9 @@ namespace // and add assertions about the highest bit. // The old scheme used the highest bit and the new one does not. // uint64_t const kTypeMask = 0x7F00000000000000; -uint64_t const kTypeMask = 0xFF00000000000000; -uint64_t const kReservedMask = 0x00FF000000000000; -uint64_t const kSerialMask = 0x0000FFFFFFFFFFFF; +uint64_t constexpr kTypeMask = 0xFF00000000000000; +uint64_t constexpr kReservedMask = 0x00FF000000000000; +uint64_t constexpr kSerialMask = 0x0000FFFFFFFFFFFF; } // namespace namespace base diff --git a/libs/base/suffix_array.cpp b/libs/base/suffix_array.cpp index 1e7b9507f..a62a47f66 100644 --- a/libs/base/suffix_array.cpp +++ b/libs/base/suffix_array.cpp @@ -96,7 +96,7 @@ Slice MakeSlice(Container const & c, size_t offset) template void RawSkew(size_t n, size_t maxValue, S const & s, size_t * sa) { - size_t const kInvalidId = std::numeric_limits::max(); + size_t constexpr kInvalidId = std::numeric_limits::max(); if (n == 0) return; diff --git a/libs/coding/bwt.cpp b/libs/coding/bwt.cpp index aaa82e9e4..15a70daa1 100644 --- a/libs/coding/bwt.cpp +++ b/libs/coding/bwt.cpp @@ -10,11 +10,11 @@ namespace { -size_t const kNumBytes = 256; +size_t constexpr kNumBytes = 256; // Fake trailing '$' for the BWT, used for original string // reconstruction. -uint32_t const kEOS = 256; +uint32_t constexpr kEOS = 256; // FirstColumn represents the first column in the BWT matrix. As // during reverse BWT we need to reconstruct canonical first column, diff --git a/libs/coding/compressed_bit_vector.cpp b/libs/coding/compressed_bit_vector.cpp index 728ac397d..0c8d7c8af 100644 --- a/libs/coding/compressed_bit_vector.cpp +++ b/libs/coding/compressed_bit_vector.cpp @@ -414,7 +414,7 @@ unique_ptr CompressedBitVectorBuilder::FromBitPositions(vec // static unique_ptr CompressedBitVectorBuilder::FromBitGroups(vector && bitGroups) { - static uint64_t const kBlockSize = DenseCBV::kBlockSize; + static uint64_t constexpr kBlockSize = DenseCBV::kBlockSize; while (!bitGroups.empty() && bitGroups.back() == 0) bitGroups.pop_back(); diff --git a/libs/coding/compressed_bit_vector.hpp b/libs/coding/compressed_bit_vector.hpp index 48f2d9477..6cfe3aa6a 100644 --- a/libs/coding/compressed_bit_vector.hpp +++ b/libs/coding/compressed_bit_vector.hpp @@ -89,7 +89,7 @@ class DenseCBV : public CompressedBitVector { public: friend class CompressedBitVectorBuilder; - static uint64_t const kBlockSize = 64; + static uint64_t constexpr kBlockSize = 64; DenseCBV() = default; diff --git a/libs/coding/files_container.hpp b/libs/coding/files_container.hpp index 04e604ef7..98f1db234 100644 --- a/libs/coding/files_container.hpp +++ b/libs/coding/files_container.hpp @@ -34,7 +34,7 @@ public: /// this value. /// /// WARNING! Existing sections may not be properly aligned. - static uint64_t const kSectionAlignment = 8; + static uint64_t constexpr kSectionAlignment = 8; bool IsExist(Tag const & tag) const { return GetInfo(tag) != 0; } diff --git a/libs/coding/hex.cpp b/libs/coding/hex.cpp index fefd7b095..1d5555937 100644 --- a/libs/coding/hex.cpp +++ b/libs/coding/hex.cpp @@ -4,7 +4,7 @@ namespace impl { -static char const kToHexTable[] = "0123456789ABCDEF"; +static char constexpr kToHexTable[] = "0123456789ABCDEF"; void ToHexRaw(void const * src, size_t size, void * dst) { diff --git a/libs/coding/huffman.cpp b/libs/coding/huffman.cpp index c5f3c6e27..1ce43e56b 100644 --- a/libs/coding/huffman.cpp +++ b/libs/coding/huffman.cpp @@ -100,7 +100,7 @@ void HuffmanCoder::SetDepths(Node * root, uint32_t depth) // One would need more than 2^32 symbols to build a code that long. // On the other hand, 32 is short enough for our purposes, so do not // try to shrink the trees beyond this threshold. - uint32_t const kMaxDepth = 32; + uint32_t constexpr kMaxDepth = 32; if (!root) return; diff --git a/libs/coding/parse_xml.hpp b/libs/coding/parse_xml.hpp index d89e6d9f0..cf2ceff6b 100644 --- a/libs/coding/parse_xml.hpp +++ b/libs/coding/parse_xml.hpp @@ -39,7 +39,7 @@ public: } private: - uint32_t static const kBufferSize = 16 * 1024; + uint32_t static constexpr kBufferSize = 16 * 1024; uint64_t m_res = 0; uint64_t m_numRead = 0; diff --git a/libs/coding/text_storage.hpp b/libs/coding/text_storage.hpp index c7b860b22..0f9dadf49 100644 --- a/libs/coding/text_storage.hpp +++ b/libs/coding/text_storage.hpp @@ -212,7 +212,7 @@ private: class BlockedTextStorageReader { public: - inline static size_t const kDefaultCacheSize = 32; + inline static size_t constexpr kDefaultCacheSize = 32; BlockedTextStorageReader() : m_cache(kDefaultCacheSize) {} explicit BlockedTextStorageReader(size_t cacheSize) : m_cache(cacheSize) {} diff --git a/libs/drape/overlay_tree.cpp b/libs/drape/overlay_tree.cpp index 5716cecc3..36700f3bc 100644 --- a/libs/drape/overlay_tree.cpp +++ b/libs/drape/overlay_tree.cpp @@ -7,14 +7,14 @@ namespace dp { -int const kMinFrameUpdatePeriod = 5; -int const kAvgFrameUpdatePeriod = 10; -int const kMaxFrameUpdatePeriod = 15; -uint32_t const kMinHandlesCount = 100; -uint32_t const kMaxHandlesCount = 1000; +int constexpr kMinFrameUpdatePeriod = 5; +int constexpr kAvgFrameUpdatePeriod = 10; +int constexpr kMaxFrameUpdatePeriod = 15; +uint32_t constexpr kMinHandlesCount = 100; +uint32_t constexpr kMaxHandlesCount = 1000; -size_t const kAverageHandlesCount[dp::OverlayRanksCount] = {300, 200, 50}; -int const kInvalidFrame = -1; +size_t constexpr kAverageHandlesCount[dp::OverlayRanksCount] = {300, 200, 50}; +int constexpr kInvalidFrame = -1; namespace { @@ -466,7 +466,7 @@ void OverlayTree::Select(m2::PointD const & glbPoint, TOverlayContainer & result ScreenBase const & screen = GetModelView(); m2::PointD const pxPoint = screen.GtoP(glbPoint); - double const kSearchRectHalfSize = 10.0; + double constexpr kSearchRectHalfSize = 10.0; m2::RectD rect(pxPoint, pxPoint); rect.Inflate(kSearchRectHalfSize, kSearchRectHalfSize); diff --git a/libs/drape/texture_of_colors.cpp b/libs/drape/texture_of_colors.cpp index f1d75cb12..7ce5635a2 100644 --- a/libs/drape/texture_of_colors.cpp +++ b/libs/drape/texture_of_colors.cpp @@ -10,8 +10,8 @@ namespace dp namespace { -int const kResourceSize = 2; -int const kBytesPerPixel = 4; +int constexpr kResourceSize = 2; +int constexpr kBytesPerPixel = 4; } // namespace ColorPalette::ColorPalette(m2::PointU const & canvasSize) : m_textureSize(canvasSize), m_cursor(m2::PointU::Zero()) {} diff --git a/libs/drape/vulkan/vulkan_memory_manager.cpp b/libs/drape/vulkan/vulkan_memory_manager.cpp index fdeae1fc3..a3db34f1f 100644 --- a/libs/drape/vulkan/vulkan_memory_manager.cpp +++ b/libs/drape/vulkan/vulkan_memory_manager.cpp @@ -13,14 +13,14 @@ namespace vulkan { namespace { -std::array const kMinBlockSizeInBytes = {{ +std::array constexpr kMinBlockSizeInBytes = {{ 1024 * 1024, // Geometry 128 * 1024, // Uniform 0, // Staging (no minimal size) 0, // Image (no minimal size) }}; -std::array const kDesiredSizeInBytes = {{ +std::array constexpr kDesiredSizeInBytes = {{ 80 * 1024 * 1024, // Geometry std::numeric_limits::max(), // Uniform (unlimited) 20 * 1024 * 1024, // Staging diff --git a/libs/drape_frontend/animation_constants.hpp b/libs/drape_frontend/animation_constants.hpp index ced06a4b0..24e2c8dbe 100644 --- a/libs/drape_frontend/animation_constants.hpp +++ b/libs/drape_frontend/animation_constants.hpp @@ -2,6 +2,6 @@ namespace df { -double const kMaxAnimationTimeSec = 1.5; // in seconds +double constexpr kMaxAnimationTimeSec = 1.5; // in seconds } // namespace df diff --git a/libs/drape_frontend/apply_feature_functors.cpp b/libs/drape_frontend/apply_feature_functors.cpp index 2f904f593..e2844af46 100644 --- a/libs/drape_frontend/apply_feature_functors.cpp +++ b/libs/drape_frontend/apply_feature_functors.cpp @@ -46,7 +46,7 @@ dp::Color ToDrapeColor(uint32_t src) namespace { -double const kMinVisibleFontSize = 8.0; +double constexpr kMinVisibleFontSize = 8.0; df::ColorConstant const kPoiDeletedMaskColor = "PoiDeletedMask"; df::ColorConstant const kRoadShieldBlackTextColor = "RoadShieldBlackText"; @@ -58,8 +58,8 @@ df::ColorConstant const kRoadShieldRedBackgroundColor = "RoadShieldRedBackground df::ColorConstant const kRoadShieldOrangeBackgroundColor = "RoadShieldOrangeBackground"; df::ColorConstant const kRoadShieldUKYellowTextColor = "RoadShieldUKYellowText"; -uint32_t const kPathTextBaseTextIndex = 128; -uint32_t const kShieldBaseTextIndex = 0; +uint32_t constexpr kPathTextBaseTextIndex = 128; +uint32_t constexpr kShieldBaseTextIndex = 0; #ifdef LINES_GENERATION_CALC_FILTERED_POINTS class LinesStat diff --git a/libs/drape_frontend/arrow3d.cpp b/libs/drape_frontend/arrow3d.cpp index 3ef62775c..449733454 100644 --- a/libs/drape_frontend/arrow3d.cpp +++ b/libs/drape_frontend/arrow3d.cpp @@ -50,7 +50,7 @@ df::ColorConstant const kArrow3DOutlineColor = "Arrow3DOutline"; std::string const kDefaultArrowMesh = "arrow.obj"; std::string const kDefaultArrowShadowMesh = "arrow_shadow.obj"; -std::string_view const kMainFileId = "main_obj_file_id"; +std::string_view constexpr kMainFileId = "main_obj_file_id"; using TLoadingCompletion = std::function positions, std::vector normals, std::vector texCoords)>; @@ -351,7 +351,7 @@ bool Arrow3d::IsValid() const // static double Arrow3d::GetMaxBottomSize() { - double const kBottomSize = 1.0; + double constexpr kBottomSize = 1.0; return kBottomSize * arrow3d::kArrowSize * arrow3d::kArrow3dScaleMax * kOutlineScale; } diff --git a/libs/drape_frontend/circles_pack_shape.cpp b/libs/drape_frontend/circles_pack_shape.cpp index eee3bd448..f86a5e97d 100644 --- a/libs/drape_frontend/circles_pack_shape.cpp +++ b/libs/drape_frontend/circles_pack_shape.cpp @@ -16,7 +16,7 @@ namespace df { namespace { -uint32_t const kDynamicStreamID = 0x7F; +uint32_t constexpr kDynamicStreamID = 0x7F; struct CirclesPackStaticVertex { diff --git a/libs/drape_frontend/colored_symbol_shape.cpp b/libs/drape_frontend/colored_symbol_shape.cpp index 779c00275..e4732170e 100644 --- a/libs/drape_frontend/colored_symbol_shape.cpp +++ b/libs/drape_frontend/colored_symbol_shape.cpp @@ -118,7 +118,7 @@ void ColoredSymbolShape::Draw(ref_ptr context, ref_ptr(m_params.m_radiusInPixels), 2 * static_cast(m_params.m_radiusInPixels)); // Here we use an equilateral triangle to render circle (incircle of a triangle). - static float const kSqrt3 = static_cast(sqrt(3.0f)); + static float constexpr kSqrt3 = static_cast(sqrt(3.0f)); float r = m_params.m_radiusInPixels - m_params.m_outlineWidth; V::TTexCoord uv2(uv.x, uv.y, norm(0.0, 0.0)); @@ -195,7 +195,7 @@ void ColoredSymbolShape::Draw(ref_ptr context, ref_ptr(sqrt(2.0f)); + static float constexpr kSqrt2 = static_cast(sqrt(2.0f)); float r = m_params.m_radiusInPixels - m_params.m_outlineWidth; V::TTexCoord uv2(uv.x, uv.y, norm(-halfWidthBody, halfHeightBody)); buffer.push_back(V(position, V::TNormal(0.0, 0.0, r, 0.0f), uv2)); diff --git a/libs/drape_frontend/frontend_renderer.cpp b/libs/drape_frontend/frontend_renderer.cpp index 641bf0a8f..d31c0db61 100644 --- a/libs/drape_frontend/frontend_renderer.cpp +++ b/libs/drape_frontend/frontend_renderer.cpp @@ -1519,7 +1519,7 @@ void FrontendRenderer::Render3dLayer(ScreenBase const & modelView) DEBUG_LABEL(m_context, "3D Layer"); if (m_buildingsFramebuffer->IsSupported()) { - float const kOpacity = 0.7f; + float constexpr kOpacity = 0.7f; m_screenQuadRenderer->RenderTexture(m_context, make_ref(m_gpuProgramManager), m_buildingsFramebuffer->GetTexture(), kOpacity); } @@ -2501,7 +2501,7 @@ void FrontendRenderer::UpdateScene(ScreenBase const & modelView) auto removePredicate = [this](drape_ptr const & group) { - uint32_t const kMaxGenerationRange = 5; + uint32_t constexpr kMaxGenerationRange = 5; TileKey const & key = group->GetTileKey(); return (GetDepthLayer(group->GetState()) == DepthLayer::OverlayLayer && key.m_zoomLevel > GetCurrentZoom()) || diff --git a/libs/drape_frontend/gps_track_renderer.cpp b/libs/drape_frontend/gps_track_renderer.cpp index e51889d67..e1b1e8b50 100644 --- a/libs/drape_frontend/gps_track_renderer.cpp +++ b/libs/drape_frontend/gps_track_renderer.cpp @@ -22,26 +22,26 @@ df::ColorConstant const kTrackCarSpeedColor = "TrackCarSpeed"; df::ColorConstant const kTrackPlaneSpeedColor = "TrackPlaneSpeed"; df::ColorConstant const kTrackHumanSpeedColor = "TrackHumanSpeed"; -int const kMinVisibleZoomLevel = 5; +int constexpr kMinVisibleZoomLevel = 5; -uint32_t const kAveragePointsCount = 512; +uint32_t constexpr kAveragePointsCount = 512; // Radius of circles depending on zoom levels. -std::array const kRadiusInPixel = { +std::array constexpr kRadiusInPixel = { // 1 2 3 4 5 6 7 8 9 10 0.8f, 0.8f, 1.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f, // 11 12 13 14 15 16 17 18 19 20 2.5f, 2.5f, 2.5f, 2.5f, 3.0f, 4.0f, 4.5f, 4.5f, 5.0f, 5.5f}; -double const kHumanSpeed = 2.6; // meters per second -double const kCarSpeed = 6.2; // meters per second -uint8_t const kMinDayAlpha = 90; -uint8_t const kMaxDayAlpha = 144; -uint8_t const kMinNightAlpha = 50; -uint8_t const kMaxNightAlpha = 102; -double const kUnknownDistanceTime = 5 * 60; // seconds +double constexpr kHumanSpeed = 2.6; // meters per second +double constexpr kCarSpeed = 6.2; // meters per second +uint8_t constexpr kMinDayAlpha = 90; +uint8_t constexpr kMaxDayAlpha = 144; +uint8_t constexpr kMinNightAlpha = 50; +uint8_t constexpr kMaxNightAlpha = 102; +double constexpr kUnknownDistanceTime = 5 * 60; // seconds -double const kDistanceScalar = 0.4; +double constexpr kDistanceScalar = 0.4; #ifdef DEBUG bool GpsPointsSortPredicate(GpsTrackPoint const & pt1, GpsTrackPoint const & pt2) diff --git a/libs/drape_frontend/gui/compass.cpp b/libs/drape_frontend/gui/compass.cpp index 7e14afe3d..8038a2e1b 100644 --- a/libs/drape_frontend/gui/compass.cpp +++ b/libs/drape_frontend/gui/compass.cpp @@ -48,9 +48,9 @@ public: bool Update(ScreenBase const & screen) override { - static double const kVisibleTolerance = 0.1; - static double const kVisibleStartAngle = math::DegToRad(0.0 + kVisibleTolerance); - static double const kVisibleEndAngle = math::DegToRad(360.0 - kVisibleTolerance); + static double constexpr kVisibleTolerance = 0.1; + static double constexpr kVisibleStartAngle = math::DegToRad(0.0 + kVisibleTolerance); + static double constexpr kVisibleEndAngle = math::DegToRad(360.0 - kVisibleTolerance); auto const angle = static_cast(ang::AngleIn2PI(screen.GetAngle())); diff --git a/libs/drape_frontend/line_shape.cpp b/libs/drape_frontend/line_shape.cpp index 5f370109d..b42c44480 100644 --- a/libs/drape_frontend/line_shape.cpp +++ b/libs/drape_frontend/line_shape.cpp @@ -198,7 +198,7 @@ private: void CreateRoundCap(glsl::vec2 const & pos) { // Here we use an equilateral triangle to render circle (incircle of a triangle). - static float const kSqrt3 = sqrt(3.0f); + static float constexpr kSqrt3 = sqrt(3.0f); float const radius = GetHalfWidth(); m_capGeometry.emplace_back(CapVertex::TPosition(pos, m_params.m_depth), diff --git a/libs/drape_frontend/line_shape_helper.cpp b/libs/drape_frontend/line_shape_helper.cpp index 104228ac0..6b9680c06 100644 --- a/libs/drape_frontend/line_shape_helper.cpp +++ b/libs/drape_frontend/line_shape_helper.cpp @@ -14,7 +14,7 @@ void UpdateNormalBetweenSegments(LineSegment * segment1, LineSegment * segment2) float const dotProduct = glsl::dot(segment1->m_leftNormals[EndPoint], segment2->m_leftNormals[StartPoint]); float const absDotProduct = fabs(dotProduct); - float const kEps = 1e-5; + float constexpr kEps = 1e-5; if (fabs(absDotProduct - 1.0f) < kEps) { @@ -22,7 +22,7 @@ void UpdateNormalBetweenSegments(LineSegment * segment1, LineSegment * segment2) return; } - float const kMaxScalar = 5; + float constexpr kMaxScalar = 5; float const crossProduct = glsl::cross(glsl::vec3(segment1->m_tangent, 0), glsl::vec3(segment2->m_tangent, 0)).z; if (crossProduct < 0) { diff --git a/libs/drape_frontend/my_position.cpp b/libs/drape_frontend/my_position.cpp index b31a39eb3..bcc9e3cc8 100644 --- a/libs/drape_frontend/my_position.cpp +++ b/libs/drape_frontend/my_position.cpp @@ -211,7 +211,7 @@ void MyPosition::CacheSymbol(ref_ptr context, dp::TextureMa void MyPosition::CachePointPosition(ref_ptr context, ref_ptr mng) { - int const kSymbolsCount = 1; + int constexpr kSymbolsCount = 1; dp::TextureManager::SymbolRegion pointSymbol; mng->GetSymbolRegion("current-position", pointSymbol); diff --git a/libs/drape_frontend/my_position_controller.cpp b/libs/drape_frontend/my_position_controller.cpp index 72a4683c2..ec02f6d60 100644 --- a/libs/drape_frontend/my_position_controller.cpp +++ b/libs/drape_frontend/my_position_controller.cpp @@ -23,19 +23,19 @@ namespace df { namespace { -int const kPositionRoutingOffsetY = 104; +int constexpr kPositionRoutingOffsetY = 104; // Speed threshold to switch to GPS bearing. Use compass for slow walking only. -double const kMinSpeedThresholdMps = 0.7; // 2.5 km/h -double const kGpsBearingLifetimeSec = 5.0; -double const kMaxTimeInBackgroundSec = 60.0 * 60 * 30; // 30 hours before starting detecting position again -double const kMaxNotFollowRoutingTimeSec = 20.0; -double const kMaxUpdateLocationInvervalSec = 30.0; -double const kMaxBlockAutoZoomTimeSec = 10.0; +double constexpr kMinSpeedThresholdMps = 0.7; // 2.5 km/h +double constexpr kGpsBearingLifetimeSec = 5.0; +double constexpr kMaxTimeInBackgroundSec = 60.0 * 60 * 30; // 30 hours before starting detecting position again +double constexpr kMaxNotFollowRoutingTimeSec = 20.0; +double constexpr kMaxUpdateLocationInvervalSec = 30.0; +double constexpr kMaxBlockAutoZoomTimeSec = 10.0; -int const kZoomThreshold = 10; -int const kMaxScaleZoomLevel = 16; -int const kDefaultAutoZoom = 16; -double const kUnknownAutoZoom = -1.0; +int constexpr kZoomThreshold = 10; +int constexpr kMaxScaleZoomLevel = 16; +int constexpr kDefaultAutoZoom = 16; +double constexpr kUnknownAutoZoom = -1.0; inline int GetZoomLevel(ScreenBase const & screen) { @@ -231,7 +231,7 @@ void MyPositionController::DragStarted() void MyPositionController::DragEnded(m2::PointD const & distance) { - float const kBindingDistance = 0.1f; + float constexpr kBindingDistance = 0.1f; m_needBlockAnimation = false; if (distance.Length() > kBindingDistance * std::min(m_pixelRect.SizeX(), m_pixelRect.SizeY())) StopLocationFollow(); diff --git a/libs/drape_frontend/navigator.cpp b/libs/drape_frontend/navigator.cpp index 87a0f327c..fc4f5e5f7 100644 --- a/libs/drape_frontend/navigator.cpp +++ b/libs/drape_frontend/navigator.cpp @@ -15,7 +15,7 @@ namespace df { -double const kDefault3dScale = 1.0; +double constexpr kDefault3dScale = 1.0; void Navigator::SetFromScreen(ScreenBase const & screen) { @@ -29,7 +29,7 @@ void Navigator::SetFromScreen(ScreenBase const & screen, uint32_t tileSize, doub if (!CheckMaxScale(tmp, tileSize, visualScale)) { - int const scale = scales::GetUpperStyleScale() - 1; + int constexpr scale = scales::GetUpperStyleScale() - 1; m2::RectD newRect = df::GetRectForDrawScale(scale, screen.GetOrg()); newRect.Scale(m_Screen.GetScale3d()); CheckMinMaxVisibleScale(newRect, scale, m_Screen.GetScale3d()); diff --git a/libs/drape_frontend/overlay_batcher.cpp b/libs/drape_frontend/overlay_batcher.cpp index eaf5a4791..9b5eabc90 100644 --- a/libs/drape_frontend/overlay_batcher.cpp +++ b/libs/drape_frontend/overlay_batcher.cpp @@ -8,12 +8,12 @@ namespace df { -uint32_t const kOverlayIndexBufferSize = 30000; -uint32_t const kOverlayVertexBufferSize = 20000; +uint32_t constexpr kOverlayIndexBufferSize = 30000; +uint32_t constexpr kOverlayVertexBufferSize = 20000; OverlayBatcher::OverlayBatcher(TileKey const & key) : m_batcher(kOverlayIndexBufferSize, kOverlayVertexBufferSize) { - int const kAverageRenderDataCount = 5; + int constexpr kAverageRenderDataCount = 5; m_data.reserve(kAverageRenderDataCount); m_batcher.SetBatcherHash(key.GetHashValue(BatcherBucket::Overlay)); diff --git a/libs/drape_frontend/path_text_handle.cpp b/libs/drape_frontend/path_text_handle.cpp index d8a7e5e2d..3c556c281 100644 --- a/libs/drape_frontend/path_text_handle.cpp +++ b/libs/drape_frontend/path_text_handle.cpp @@ -10,11 +10,11 @@ namespace df namespace { -double const kValidPathSplineTurn = 15 * math::pi / 180; -double const kCosTurn = cos(kValidPathSplineTurn); -double const kSinTurn = sin(kValidPathSplineTurn); -double const kRoundStep = 23; -int const kMaxStepsCount = 7; +double constexpr kValidPathSplineTurn = 15 * math::pi / 180; +double constexpr kCosTurn = cos(kValidPathSplineTurn); +double constexpr kSinTurn = sin(kValidPathSplineTurn); +double constexpr kRoundStep = 23; +int constexpr kMaxStepsCount = 7; bool RoundCorner(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3, int leftStepsCount, std::vector & roundedCorner) @@ -31,7 +31,7 @@ bool RoundCorner(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const return false; double const vs = df::VisualParams::Instance().GetVisualScale(); - double const kMinCornerDist = 1.0; + double constexpr kMinCornerDist = 1.0; if ((p3 - p1).SquaredLength() < kMinCornerDist * vs) { roundedCorner.push_back(p1); @@ -72,7 +72,7 @@ void ReplaceLastCorner(std::vector const & roundedCorner, m2::Spline bool IsValidSplineTurn(m2::PointD const & normalizedDir1, m2::PointD const & normalizedDir2) { double const dotProduct = m2::DotProduct(normalizedDir1, normalizedDir2); - double const kEps = 1e-5; + double constexpr kEps = 1e-5; return dotProduct > kCosTurn || fabs(dotProduct - kCosTurn) < kEps; } diff --git a/libs/drape_frontend/route_renderer.cpp b/libs/drape_frontend/route_renderer.cpp index 978a8d4e4..bb70b9e14 100644 --- a/libs/drape_frontend/route_renderer.cpp +++ b/libs/drape_frontend/route_renderer.cpp @@ -32,18 +32,18 @@ std::string const kRouteFakeOutlineColor = "RouteFakeOutline"; namespace { -std::array const kPreviewPointRadiusInPixel = { +std::array constexpr kPreviewPointRadiusInPixel = { // 1 2 3 4 5 6 7 8 9 10 0.8f, 0.8f, 2.0f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f, // 11 12 13 14 15 16 17 18 19 20 2.5f, 2.5f, 2.5f, 2.5f, 3.0f, 4.0f, 4.5f, 4.5f, 5.0f, 5.5f}; -int const kArrowAppearingZoomLevel = 14; -int const kInvalidGroup = -1; +int constexpr kArrowAppearingZoomLevel = 14; +int constexpr kInvalidGroup = -1; -uint32_t const kPreviewPointsCount = 512; +uint32_t constexpr kPreviewPointsCount = 512; -double const kInvalidDistance = -1.0; +double constexpr kInvalidDistance = -1.0; void InterpolateByZoom(SubrouteConstPtr const & subroute, ScreenBase const & screen, float & halfWidth, double & zoom) { @@ -111,7 +111,7 @@ bool AreEqualArrowBorders(std::vector const & borders1, std::vecto if (borders1[i].m_groupIndex != borders2[i].m_groupIndex) return false; - double const kDistanceEps = 1e-5; + double constexpr kDistanceEps = 1e-5; for (size_t i = 0; i < borders1.size(); i++) { if (fabs(borders1[i].m_startDistance - borders2[i].m_startDistance) > kDistanceEps) diff --git a/libs/drape_frontend/route_shape.cpp b/libs/drape_frontend/route_shape.cpp index 92aeeca0d..bcd31ad15 100644 --- a/libs/drape_frontend/route_shape.cpp +++ b/libs/drape_frontend/route_shape.cpp @@ -21,34 +21,17 @@ namespace df { -std::array const kRouteHalfWidthInPixelCar = { - // 1 2 3 4 5 6 7 8 9 10 - 1.0f, 1.2f, 1.5f, 1.5f, 1.7f, 2.0f, 2.0f, 2.3f, 2.5f, 2.7f, - // 11 12 13 14 15 16 17 18 19 20 - 3.0f, 3.5f, 4.5f, 5.5f, 7.0, 9.0f, 10.0f, 14.0f, 22.0f, 27.0f}; - -std::array const kRouteHalfWidthInPixelTransit = { - // 1 2 3 4 5 6 7 8 9 10 - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.7f, - // 11 12 13 14 15 16 17 18 19 20 - 1.8f, 2.1f, 2.5f, 2.8f, 3.5, 4.5f, 5.0f, 7.0f, 11.0f, 13.0f}; - -std::array const kRouteHalfWidthInPixelOthers = { - // 1 2 3 4 5 6 7 8 9 10 - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.1f, 1.2f, 1.3f, - // 11 12 13 14 15 16 17 18 19 20 - 1.5f, 1.7f, 2.3f, 2.7f, 3.5, 4.5f, 5.0f, 7.0f, 11.0f, 13.0f}; namespace rs { -float const kLeftSide = 1.0f; -float const kCenter = 0.0f; -float const kRightSide = -1.0f; +float constexpr kLeftSide = 1.0f; +float constexpr kCenter = 0.0f; +float constexpr kRightSide = -1.0f; -float const kRouteDepth = 99.0f; -float const kMarkersDepth = 100.0f; -float const kArrowsDepth = 200.0f; -float const kDepthPerSubroute = 200.0f; +float constexpr kRouteDepth = 99.0f; +float constexpr kMarkersDepth = 100.0f; +float constexpr kArrowsDepth = 200.0f; +float constexpr kDepthPerSubroute = 200.0f; void GetArrowTextureRegion(ref_ptr textures, dp::TextureManager::SymbolRegion & region) { @@ -106,7 +89,7 @@ void CalculatePoints(m2::PolylineD const & polyline, double start, double end, s float SideByNormal(glsl::vec2 const & normal, bool isLeft) { - float const kEps = 1e-5; + float constexpr kEps = 1e-5; float const side = isLeft ? kLeftSide : kRightSide; return glsl::length(normal) < kEps ? kCenter : side; } @@ -399,10 +382,10 @@ void RouteShape::PrepareMarkersGeometry(std::vector const & mark { ASSERT(!markers.empty(), ()); - static float const kSqrt3 = sqrt(3.0f); - static float const kSqrt2 = sqrt(2.0f); - static float const kInnerRadius = 0.6f; - static float const kOuterRadius = 1.0f; + static float constexpr kSqrt3 = sqrt(3.0f); + static float constexpr kSqrt2 = sqrt(2.0f); + static float constexpr kInnerRadius = 0.6f; + static float constexpr kOuterRadius = 1.0f; float const depth = baseDepth - 0.5f; float const innerDepth = baseDepth + 0.5f; @@ -589,7 +572,7 @@ drape_ptr RouteShape::CacheMarkers(ref_ptr(BatcherBucket::Routing)); dp::SessionGuard guard(context, batcher, diff --git a/libs/drape_frontend/route_shape.hpp b/libs/drape_frontend/route_shape.hpp index 3db05fa3a..e1ec8c774 100644 --- a/libs/drape_frontend/route_shape.hpp +++ b/libs/drape_frontend/route_shape.hpp @@ -20,25 +20,39 @@ namespace df { -double const kArrowSize = 0.0008; +double constexpr kArrowSize = 0.0008; // Constants below depend on arrow texture. -double const kArrowTextureWidth = 74.0; -double const kArrowTextureHeight = 44.0; -double const kArrowBodyHeight = 24.0; -double const kArrowHeadTextureWidth = 32.0; -double const kArrowTailTextureWidth = 4.0; +double constexpr kArrowTextureWidth = 74.0; +double constexpr kArrowTextureHeight = 44.0; +double constexpr kArrowBodyHeight = 24.0; +double constexpr kArrowHeadTextureWidth = 32.0; +double constexpr kArrowTailTextureWidth = 4.0; -double const kArrowHeadSize = kArrowHeadTextureWidth / kArrowTextureWidth; -float const kArrowHeadFactor = static_cast(2.0 * kArrowHeadTextureWidth / kArrowTextureHeight); -double const kArrowTailSize = kArrowTailTextureWidth / kArrowTextureWidth; -float const kArrowTailFactor = static_cast(2.0 * kArrowTailTextureWidth / kArrowTextureHeight); -double const kArrowHeightFactor = kArrowTextureHeight / kArrowBodyHeight; -double const kArrowAspect = kArrowTextureWidth / kArrowTextureHeight; +double constexpr kArrowHeadSize = kArrowHeadTextureWidth / kArrowTextureWidth; +float constexpr kArrowHeadFactor = static_cast(2.0 * kArrowHeadTextureWidth / kArrowTextureHeight); +double constexpr kArrowTailSize = kArrowTailTextureWidth / kArrowTextureWidth; +float constexpr kArrowTailFactor = static_cast(2.0 * kArrowTailTextureWidth / kArrowTextureHeight); +double constexpr kArrowHeightFactor = kArrowTextureHeight / kArrowBodyHeight; +double constexpr kArrowAspect = kArrowTextureWidth / kArrowTextureHeight; -extern std::array const kRouteHalfWidthInPixelCar; -extern std::array const kRouteHalfWidthInPixelTransit; -extern std::array const kRouteHalfWidthInPixelOthers; +std::array constexpr kRouteHalfWidthInPixelCar = { + // 1 2 3 4 5 6 7 8 9 10 + 1.0f, 1.2f, 1.5f, 1.5f, 1.7f, 2.0f, 2.0f, 2.3f, 2.5f, 2.7f, + // 11 12 13 14 15 16 17 18 19 20 + 3.0f, 3.5f, 4.5f, 5.5f, 7.0, 9.0f, 10.0f, 14.0f, 22.0f, 27.0f}; + +std::array constexpr kRouteHalfWidthInPixelTransit = { + // 1 2 3 4 5 6 7 8 9 10 + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.7f, + // 11 12 13 14 15 16 17 18 19 20 + 1.8f, 2.1f, 2.5f, 2.8f, 3.5, 4.5f, 5.0f, 7.0f, 11.0f, 13.0f}; + +std::array constexpr kRouteHalfWidthInPixelOthers = { + // 1 2 3 4 5 6 7 8 9 10 + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.1f, 1.2f, 1.3f, + // 11 12 13 14 15 16 17 18 19 20 + 1.5f, 1.7f, 2.3f, 2.7f, 3.5, 4.5f, 5.0f, 7.0f, 11.0f, 13.0f}; enum class RouteType : uint8_t { @@ -59,7 +73,7 @@ struct RoutePattern bool operator==(RoutePattern const & pattern) const { - double const kEps = 1e-5; + double constexpr kEps = 1e-5; return m_isDashed == pattern.m_isDashed && std::fabs(m_dashLength - pattern.m_dashLength) < kEps && std::fabs(m_gapLength - pattern.m_gapLength) < kEps; } diff --git a/libs/drape_frontend/rule_drawer.cpp b/libs/drape_frontend/rule_drawer.cpp index 298053ffe..a59e4180c 100644 --- a/libs/drape_frontend/rule_drawer.cpp +++ b/libs/drape_frontend/rule_drawer.cpp @@ -38,7 +38,7 @@ namespace { // The first zoom level in kAverageSegmentsCount. int constexpr kFirstZoomInAverageSegments = 10; -std::array const kAverageSegmentsCount = { +std::array constexpr kAverageSegmentsCount = { // 10 11 12 13 14 15 16 17 18 19 10000, 5000, 10000, 5000, 2500, 5000, 2000, 1000, 500, 500}; @@ -131,7 +131,7 @@ void ExtractTrafficGeometry(FeatureType const & f, df::RoadClass const & roadCla ASSERT_EQUAL(segment.size(), 2, ()); // Skip zero-length segments. - double const kEps = 1e-5; + double constexpr kEps = 1e-5; if (segment[0].EqualDxDy(segment[1], kEps)) break; @@ -183,7 +183,7 @@ RuleDrawer::RuleDrawer(TCheckCancelledCallback const & checkCancelled, TIsCountr geometryConvertor.SetFromRect(m2::AnyRectD(r)); m_trafficScalePtoG = geometryConvertor.GetScale(); - int const kAverageOverlaysCount = 200; + int constexpr kAverageOverlaysCount = 200; m_mapShapes[df::OverlayType].reserve(kAverageOverlaysCount); } diff --git a/libs/drape_frontend/selection_shape.cpp b/libs/drape_frontend/selection_shape.cpp index 613e048f5..11a5e3428 100644 --- a/libs/drape_frontend/selection_shape.cpp +++ b/libs/drape_frontend/selection_shape.cpp @@ -17,7 +17,7 @@ namespace df { namespace { -std::array const kHalfLineWidthInPixel = { +std::array constexpr kHalfLineWidthInPixel = { // 1 2 3 4 5 6 7 8 9 10 1.0f, 1.2f, 1.5f, 1.5f, 1.7f, 2.0f, 2.0f, 2.3f, 2.5f, 2.7f, // 11 12 13 14 15 16 17 18 19 20 diff --git a/libs/drape_frontend/selection_shape_generator.cpp b/libs/drape_frontend/selection_shape_generator.cpp index 5ce142367..762046808 100644 --- a/libs/drape_frontend/selection_shape_generator.cpp +++ b/libs/drape_frontend/selection_shape_generator.cpp @@ -26,9 +26,9 @@ namespace { std::string const kTrackSelectedSymbolName = "track_marker_selected"; df::ColorConstant const kSelectionColor = "Selection"; -float const kLeftSide = 1.0f; -float const kCenter = 0.0f; -float const kRightSide = -1.0f; +float constexpr kLeftSide = 1.0f; +float constexpr kCenter = 0.0f; +float constexpr kRightSide = -1.0f; struct MarkerVertex { @@ -91,7 +91,7 @@ dp::BindingInfo GetSelectionLineVertexBindingInfo() float SideByNormal(glsl::vec2 const & normal, bool isLeft) { - float const kEps = 1e-5; + float constexpr kEps = 1e-5; float const side = isLeft ? kLeftSide : kRightSide; return glsl::length(normal) < kEps ? kCenter : side; } diff --git a/libs/drape_frontend/tile_info.cpp b/libs/drape_frontend/tile_info.cpp index 3f20241e3..e15971d49 100644 --- a/libs/drape_frontend/tile_info.cpp +++ b/libs/drape_frontend/tile_info.cpp @@ -36,7 +36,7 @@ void TileInfo::ReadFeatureIndex(MapDataProvider const & model) ThrowIfCancelled(); - size_t const kAverageFeaturesCount = 256; + size_t constexpr kAverageFeaturesCount = 256; m_featureInfo.reserve(kAverageFeaturesCount); MwmSet::MwmId lastMwm; diff --git a/libs/drape_frontend/traffic_generator.cpp b/libs/drape_frontend/traffic_generator.cpp index bed4d4393..b1a2bcf93 100644 --- a/libs/drape_frontend/traffic_generator.cpp +++ b/libs/drape_frontend/traffic_generator.cpp @@ -101,7 +101,7 @@ void SubmitCircleStaticVertices(RoadClass roadClass, glsl::vec3 const & pivot, g glsl::vec2 const & uv, std::vector & circlesGeometry) { // Here we use an equilateral triangle to render circle (incircle of a triangle). - static float const kSqrt3 = sqrt(3.0f); + static float constexpr kSqrt3 = sqrt(3.0f); auto const p = glsl::vec4(pivot, static_cast(roadClass)); circlesGeometry.emplace_back(p, glsl::vec4(rightNormal, -kSqrt3, -1.0f), uv); circlesGeometry.emplace_back(p, glsl::vec4(rightNormal, kSqrt3, -1.0f), uv); @@ -138,7 +138,7 @@ void TrafficGenerator::GenerateSegmentsGeometry(ref_ptr con traffic::TrafficInfo::Coloring const & coloring, ref_ptr texturesMgr) { - static std::array const kGenerateCirclesZoomLevel = {14, 14, 16}; + static std::array constexpr kGenerateCirclesZoomLevel = {14, 14, 16}; ASSERT(m_colorsCacheValid, ()); auto const colorTexture = m_colorsCache[static_cast(traffic::SpeedGroup::G0)].GetTexture(); @@ -161,7 +161,7 @@ void TrafficGenerator::GenerateSegmentsGeometry(ref_ptr con isLeftHand = (regionData.Get(feature::RegionData::RD_DRIVING) == "l"); } - static std::array const kRoadClassDepths = {30.0f, 20.0f, 10.0f}; + static std::array constexpr kRoadClassDepths = {30.0f, 20.0f, 10.0f}; for (auto const & geomPair : geometry) { diff --git a/libs/drape_frontend/traffic_renderer.cpp b/libs/drape_frontend/traffic_renderer.cpp index 594c5d861..c48eb1ac8 100644 --- a/libs/drape_frontend/traffic_renderer.cpp +++ b/libs/drape_frontend/traffic_renderer.cpp @@ -31,41 +31,41 @@ int constexpr kMinVisibleArrowZoomLevel = 16; int constexpr kRoadClass2MinVisibleArrowZoomLevel = 17; int constexpr kOutlineMinZoomLevel = 14; -float const kTrafficArrowAspect = 128.0f / 8.0f; +float constexpr kTrafficArrowAspect = 128.0f / 8.0f; -std::array const kLeftWidthInPixel = { +std::array constexpr kLeftWidthInPixel = { // 1 2 3 4 5 6 7 8 9 10 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, // 11 12 13 14 15 16 17 18 19 20 0.5f, 0.5f, 0.5f, 0.6f, 1.6f, 2.7f, 3.5f, 4.0f, 4.0f, 4.0f}; -std::array const kRightWidthInPixel = { +std::array constexpr kRightWidthInPixel = { // 1 2 3 4 5 6 7 8 9 10 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.5f, 3.0f, 3.0f, // 11 12 13 14 15 16 17 18 19 20 3.0f, 3.5f, 4.0f, 3.9f, 3.2f, 2.7f, 3.5f, 4.0f, 4.0f, 4.0f}; -std::array const kRoadClass1WidthScalar = { +std::array constexpr kRoadClass1WidthScalar = { // 1 2 3 4 5 6 7 8 9 10 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.3, // 11 12 13 14 15 16 17 18 19 20 0.3, 0.35f, 0.45f, 0.55f, 0.6f, 0.8f, 1.0f, 1.0f, 1.0f, 1.0f}; -std::array const kRoadClass2WidthScalar = { +std::array constexpr kRoadClass2WidthScalar = { // 1 2 3 4 5 6 7 8 9 10 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.3f, // 11 12 13 14 15 16 17 18 19 20 0.3f, 0.3f, 0.3f, 0.4f, 0.5f, 0.5f, 0.65f, 0.85f, 0.95f, 1.0f}; -std::array const kTwoWayOffsetInPixel = { +std::array constexpr kTwoWayOffsetInPixel = { // 1 2 3 4 5 6 7 8 9 10 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, // 11 12 13 14 15 16 17 18 19 20 0.0f, 0.5f, 0.5f, 0.75f, 1.7f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f}; -std::array const kLineDrawerRoadClass1 = {12, 13, 14}; +std::array constexpr kLineDrawerRoadClass1 = {12, 13, 14}; -std::array const kLineDrawerRoadClass2 = {15, 16}; +std::array constexpr kLineDrawerRoadClass2 = {15, 16}; float CalculateHalfWidth(ScreenBase const & screen, RoadClass const & roadClass, bool left) { @@ -206,7 +206,7 @@ void TrafficRenderer::RenderTraffic(ref_ptr context, ref_pt float const leftPixelHalfWidth = CalculateHalfWidth(screen, renderData.m_roadClass, true /* left */); float const invLeftPixelLength = 1.0f / (2.0f * leftPixelHalfWidth * kTrafficArrowAspect); float const rightPixelHalfWidth = CalculateHalfWidth(screen, renderData.m_roadClass, false /* left */); - float const kEps = 1e-5; + float constexpr kEps = 1e-5; if (fabs(leftPixelHalfWidth) < kEps && fabs(rightPixelHalfWidth) < kEps) continue; @@ -249,7 +249,7 @@ float TrafficRenderer::GetTwoWayOffset(RoadClass const & roadClass, int zoomLeve { // There is no offset for class-0 roads, the offset for them is created by // kLeftWidthInPixel and kRightWidthInPixel. - int const kRoadClass0MinZoomLevel = 14; + int constexpr kRoadClass0MinZoomLevel = 14; if (roadClass == RoadClass::Class0 && zoomLevel <= kRoadClass0MinZoomLevel) return 0.0f; diff --git a/libs/drape_frontend/transit_scheme_builder.cpp b/libs/drape_frontend/transit_scheme_builder.cpp index 74813b473..bfec1b123 100644 --- a/libs/drape_frontend/transit_scheme_builder.cpp +++ b/libs/drape_frontend/transit_scheme_builder.cpp @@ -118,7 +118,7 @@ void GenerateLineCaps(ref_ptr context, std::vector context, st auto const color = glsl::vec4(colorConst.GetRedF(), colorConst.GetGreenF(), colorConst.GetBlueF(), colorConst.GetAlphaF()); size_t const kAverageSize = path.size() * 6; - size_t const kAverageCapSize = 12; + size_t constexpr kAverageCapSize = 12; geometry.reserve(kAverageSize + kAverageCapSize * 2); std::vector segments; @@ -1133,8 +1133,8 @@ void TransitSchemeBuilder::GenerateStop(ref_ptr context, St return; } - float const kInnerScale = 0.8f; - float const kOuterScale = 2.0f; + float constexpr kInnerScale = 0.8f; + float constexpr kOuterScale = 2.0f; auto const lineId = *stopParams.m_stopsInfo.begin()->second.m_lines.begin(); auto const colorName = df::GetTransitColorName(lines.at(lineId).m_color); @@ -1210,8 +1210,8 @@ void TransitSchemeBuilder::GenerateStop(ref_ptr context, St return; } - float const kInnerScale = 0.8f; - float const kOuterScale = 2.0f; + float constexpr kInnerScale = 0.8f; + float constexpr kOuterScale = 2.0f; ::transit::TransitId lineId = *stopParams.m_stopsInfo.begin()->second.m_lines.begin(); @@ -1397,8 +1397,8 @@ void TransitSchemeBuilder::GenerateTransfer(ref_ptr context } } - float const kInnerScale = 1.0f; - float const kOuterScale = 1.5f; + float constexpr kInnerScale = 1.0f; + float constexpr kOuterScale = 1.5f; auto const outerColor = GetColorConstant(kTransitTransferOuterColor); auto const innerColor = GetColorConstant(kTransitTransferInnerColor); @@ -1423,8 +1423,8 @@ void TransitSchemeBuilder::GenerateTransfer(ref_ptr context CHECK_GREATER(maxLinesCount, 0, ()); - float const kInnerScale = 1.0f; - float const kOuterScale = 1.5f; + float constexpr kInnerScale = 1.0f; + float constexpr kOuterScale = 1.5f; auto const outerColor = GetColorConstant(kTransitTransferOuterColor); auto const innerColor = GetColorConstant(kTransitTransferInnerColor); diff --git a/libs/drape_frontend/user_event_stream.cpp b/libs/drape_frontend/user_event_stream.cpp index c21495520..be8f90629 100644 --- a/libs/drape_frontend/user_event_stream.cpp +++ b/libs/drape_frontend/user_event_stream.cpp @@ -1246,11 +1246,11 @@ void UserEventStream::UpdateDoubleTapAndHold(Touch const & touch) { TEST_CALL(DOUBLE_TAP_AND_HOLD); ASSERT_EQUAL(m_state, STATE_DOUBLE_TAP_HOLD, ()); - float const kPowerModifier = 10.0f; + float constexpr kPowerModifier = 10.0f; #if defined(OMIM_OS_IPHONE) || defined(OMIM_OS_MAC) - int const kPlatformScaleModifier = -1; + int constexpr kPlatformScaleModifier = -1; #else - int const kPlatformScaleModifier = 1; + int constexpr kPlatformScaleModifier = 1; #endif double const scaleFactor = exp(kPowerModifier * (touch.m_location.y - m_startDoubleTapAndHold.y) / GetCurrentScreen().PixelRectIn3d().SizeY() * kPlatformScaleModifier); diff --git a/libs/drape_frontend/user_event_stream.hpp b/libs/drape_frontend/user_event_stream.hpp index 3e27b69fb..fba39abad 100644 --- a/libs/drape_frontend/user_event_stream.hpp +++ b/libs/drape_frontend/user_event_stream.hpp @@ -21,8 +21,8 @@ namespace df { -int const kDoNotChangeZoom = -1; -double const kDoNotAutoZoom = -1.0; +int constexpr kDoNotChangeZoom = -1; +double constexpr kDoNotAutoZoom = -1.0; using TAnimationCreator = std::function(ref_ptr)>; diff --git a/libs/drape_frontend/user_mark_generator.cpp b/libs/drape_frontend/user_mark_generator.cpp index dbe1ef195..97b10f648 100644 --- a/libs/drape_frontend/user_mark_generator.cpp +++ b/libs/drape_frontend/user_mark_generator.cpp @@ -12,7 +12,7 @@ namespace df { -std::array const kLineIndexingLevels = {1, 7, 11}; +std::array constexpr kLineIndexingLevels = {1, 7, 11}; UserMarkGenerator::UserMarkGenerator(TFlushFn const & flushFn) : m_flushFn(flushFn) { diff --git a/libs/drape_frontend/visual_params.cpp b/libs/drape_frontend/visual_params.cpp index 9182520d7..74c16356b 100644 --- a/libs/drape_frontend/visual_params.cpp +++ b/libs/drape_frontend/visual_params.cpp @@ -128,21 +128,21 @@ uint32_t VisualParams::GetTileSize() const uint32_t VisualParams::GetTouchRectRadius() const { ASSERT_INITED; - float const kRadiusInPixels = 20.0f; + float constexpr kRadiusInPixels = 20.0f; return static_cast(kRadiusInPixels * GetVisualScale()); } double VisualParams::GetDragThreshold() const { ASSERT_INITED; - double const kDragThresholdInPixels = 10.0; + double constexpr kDragThresholdInPixels = 10.0; return kDragThresholdInPixels * GetVisualScale(); } double VisualParams::GetScaleThreshold() const { ASSERT_INITED; - double const kScaleThresholdInPixels = 2.0; + double constexpr kScaleThresholdInPixels = 2.0; return kScaleThresholdInPixels * GetVisualScale(); } @@ -305,7 +305,7 @@ void ExtractZoomFactors(ScreenBase const & s, double & zoom, int & index, float double GetNormalizedZoomLevel(double screenScale, int minZoom) { - double const kMaxZoom = scales::GetUpperStyleScale() + 1.0; + double constexpr kMaxZoom = scales::GetUpperStyleScale() + 1.0; return math::Clamp((GetZoomLevel(screenScale) - minZoom) / (kMaxZoom - minZoom), 0.0, 1.0); } diff --git a/libs/editor/changeset_wrapper.cpp b/libs/editor/changeset_wrapper.cpp index 75198344b..a26a6fcd2 100644 --- a/libs/editor/changeset_wrapper.cpp +++ b/libs/editor/changeset_wrapper.cpp @@ -177,7 +177,7 @@ editor::XMLFeature ChangesetWrapper::GetMatchingNodeFeatureFromOSM(m2::PointD co editor::XMLFeature ChangesetWrapper::GetMatchingAreaFeatureFromOSM(std::vector const & geometry) { - auto const kSamplePointsCount = 3; + auto constexpr kSamplePointsCount = 3; bool hasRelation = false; // Try several points in case of poor osm response. for (auto const & pt : NaiveSample(geometry, kSamplePointsCount)) diff --git a/libs/editor/feature_matcher.cpp b/libs/editor/feature_matcher.cpp index c3147d49c..0fb2e3d6a 100644 --- a/libs/editor/feature_matcher.cpp +++ b/libs/editor/feature_matcher.cpp @@ -29,7 +29,7 @@ using AreaType = bg::default_area_result::type; using ForEachRefFn = std::function; using ForEachWayFn = std::function; -double const kPointDiffEps = 1e-5; +double constexpr kPointDiffEps = 1e-5; void AddInnerIfNeeded(pugi::xml_document const & osmResponse, pugi::xml_node const & way, Polygon & dest) { diff --git a/libs/ge0/parser.cpp b/libs/ge0/parser.cpp index 8cd997101..8c71a30d2 100644 --- a/libs/ge0/parser.cpp +++ b/libs/ge0/parser.cpp @@ -48,11 +48,11 @@ bool Ge0Parser::Parse(std::string const & url, Result & result) bool Ge0Parser::ParseAfterPrefix(std::string const & url, size_t from, Result & result) { - size_t const kEncodedZoomAndCoordinatesLength = 10; + size_t constexpr kEncodedZoomAndCoordinatesLength = 10; if (url.size() < from + kEncodedZoomAndCoordinatesLength) return false; - size_t const kMaxNameLength = 256; + size_t constexpr kMaxNameLength = 256; size_t const posZoom = from; size_t const posLatLon = posZoom + 1; diff --git a/libs/ge0/url_generator.hpp b/libs/ge0/url_generator.hpp index b3c707b03..2c9ddb83d 100644 --- a/libs/ge0/url_generator.hpp +++ b/libs/ge0/url_generator.hpp @@ -5,8 +5,8 @@ namespace ge0 { // Max number of base64 bytes to encode a geo point. -inline static int const kMaxPointBytes = 10; -inline static int const kMaxCoordBits = kMaxPointBytes * 3; +inline static int constexpr kMaxPointBytes = 10; +inline static int constexpr kMaxCoordBits = kMaxPointBytes * 3; // Generates a short url. // diff --git a/libs/geometry/clipping.cpp b/libs/geometry/clipping.cpp index ec77747a9..f1fa36bc1 100644 --- a/libs/geometry/clipping.cpp +++ b/libs/geometry/clipping.cpp @@ -235,7 +235,7 @@ void ClipPathByRectBeforeSmooth(m2::RectD const & rect, std::vector m2::PointD guideFront; m2::PointD guideBack; - double const kEps = 1e-5; + double constexpr kEps = 1e-5; if (path.front().EqualDxDy(path.back(), kEps)) { guideFront = path[path.size() - 2]; diff --git a/libs/geometry/intersection_score.hpp b/libs/geometry/intersection_score.hpp index 0159fa82d..1abc7fa18 100644 --- a/libs/geometry/intersection_score.hpp +++ b/libs/geometry/intersection_score.hpp @@ -114,7 +114,7 @@ impl::Polygon PointsToPolygon(Container const & points) template impl::MultiPolygon TrianglesToPolygon(Container const & points) { - size_t const kTriangleSize = 3; + size_t constexpr kTriangleSize = 3; if (points.size() % kTriangleSize != 0) MYTHROW(geometry::NotAPolygonException, ("Count of points must be multiple of", kTriangleSize)); diff --git a/libs/geometry/region2d.hpp b/libs/geometry/region2d.hpp index 0f8f39c3c..e3a4b3266 100644 --- a/libs/geometry/region2d.hpp +++ b/libs/geometry/region2d.hpp @@ -330,7 +330,7 @@ public: std::uniform_real_distribution<> distrX(m_rect.minX(), m_rect.maxX()); std::uniform_real_distribution<> distrY(m_rect.minY(), m_rect.maxY()); - size_t const kMaxIterations = 1000; + size_t constexpr kMaxIterations = 1000; for (size_t it = 0; it < kMaxIterations; ++it) { auto const x = distrX(engine); diff --git a/libs/geometry/segment2d.cpp b/libs/geometry/segment2d.cpp index 5e0cd32be..6a2a402cb 100644 --- a/libs/geometry/segment2d.cpp +++ b/libs/geometry/segment2d.cpp @@ -36,7 +36,7 @@ bool IsPointOnSegment(PointD const & pt, PointD const & p1, PointD const & p2) // better ideas how to check whether pt belongs to (p1, p2) segment // more precisely or without kEps, feel free to submit a pull // request. - double const kEps = 1e-100; + double constexpr kEps = 1e-100; return IsPointOnSegmentEps(pt, p1, p2, kEps); } diff --git a/libs/indexer/editable_map_object.cpp b/libs/indexer/editable_map_object.cpp index d6758b436..53856ef0d 100644 --- a/libs/indexer/editable_map_object.cpp +++ b/libs/indexer/editable_map_object.cpp @@ -490,8 +490,8 @@ bool EditableMapObject::ValidatePhoneList(string const & phone) if (phone.empty()) return true; - auto const kMaxNumberLen = 15; - auto const kMinNumberLen = 5; + auto constexpr kMaxNumberLen = 15; + auto constexpr kMinNumberLen = 5; if (phone.size() < kMinNumberLen) return false; diff --git a/libs/indexer/feature_to_osm.hpp b/libs/indexer/feature_to_osm.hpp index 7f3f8fc26..9880c7292 100644 --- a/libs/indexer/feature_to_osm.hpp +++ b/libs/indexer/feature_to_osm.hpp @@ -130,9 +130,9 @@ public: }; inline static std::string const kHeaderMagic = "mwmftosm"; - inline static Version const kLatestVersion = FeatureIdToGeoObjectIdSerDes::Version::V0; - inline static size_t const kMagicAndVersionSize = 9; - inline static size_t const kHeaderOffset = 16; + inline static Version constexpr kLatestVersion = FeatureIdToGeoObjectIdSerDes::Version::V0; + inline static size_t constexpr kMagicAndVersionSize = 9; + inline static size_t constexpr kHeaderOffset = 16; struct HeaderV0 { diff --git a/libs/indexer/feature_visibility.cpp b/libs/indexer/feature_visibility.cpp index 2e49656bd..2ffbf61d2 100644 --- a/libs/indexer/feature_visibility.cpp +++ b/libs/indexer/feature_visibility.cpp @@ -303,7 +303,7 @@ int GetMinDrawableScale(FeatureType & ft) int GetMinDrawableScale(TypesHolder const & types, m2::RectD const & limitRect) { - int const upBound = scales::GetUpperStyleScale(); + int constexpr upBound = scales::GetUpperStyleScale(); for (int level = 0; level <= upBound; ++level) if (IsDrawableForIndex(types, limitRect, level)) @@ -315,7 +315,7 @@ int GetMinDrawableScale(TypesHolder const & types, m2::RectD const & limitRect) /* int GetMinDrawableScaleGeometryOnly(TypesHolder const & types, m2::RectD const & limitRect) { - int const upBound = scales::GetUpperStyleScale(); + int constexpr upBound = scales::GetUpperStyleScale(); for (int level = 0; level <= upBound; ++level) { @@ -329,7 +329,7 @@ int GetMinDrawableScaleGeometryOnly(TypesHolder const & types, m2::RectD const & int GetMinDrawableScaleClassifOnly(TypesHolder const & types) { - int const upBound = scales::GetUpperStyleScale(); + int constexpr upBound = scales::GetUpperStyleScale(); for (int level = 0; level <= upBound; ++level) if (IsDrawableForIndexClassifOnly(types, level)) @@ -406,7 +406,7 @@ bool IsDrawableForRules(TypesHolder const & types, int level, int rules) pair GetDrawableScaleRangeForRules(TypesHolder const & types, int rules) { - int const upBound = scales::GetUpperStyleScale(); + int constexpr upBound = scales::GetUpperStyleScale(); int lowL = -1; for (int level = 0; level <= upBound; ++level) { diff --git a/libs/kml/serdes.cpp b/libs/kml/serdes.cpp index b1007a6a2..38f694568 100644 --- a/libs/kml/serdes.cpp +++ b/libs/kml/serdes.cpp @@ -26,7 +26,7 @@ std::string_view constexpr kPair = "Pair"; std::string_view constexpr kExtendedData = "ExtendedData"; std::string const kCompilation = "mwm:compilation"; -std::string_view const kCoordinates = "coordinates"; +std::string_view constexpr kCoordinates = "coordinates"; bool IsTrack(std::string const & s) { diff --git a/libs/map/bookmark_manager.cpp b/libs/map/bookmark_manager.cpp index e52e13643..89065ca71 100644 --- a/libs/map/bookmark_manager.cpp +++ b/libs/map/bookmark_manager.cpp @@ -41,9 +41,9 @@ std::string const kLastEditedBookmarkColor = "LastBookmarkColor"; std::string const kMetadataFileName = "bm.json"; std::string const kSortingTypeProperty = "sortingType"; std::string const kLargestBookmarkSymbolName = "bookmark-default-m"; -size_t const kMinCommonTypesCount = 3; -double const kNearDistanceInMeters = 20 * 1000.0; -double const kMyPositionTrackSnapInMeters = 20.0; +size_t constexpr kMinCommonTypesCount = 3; +double constexpr kNearDistanceInMeters = 20 * 1000.0; +double constexpr kMyPositionTrackSnapInMeters = 20.0; std::string const kKMZMimeType = "application/vnd.google-earth.kmz"; std::string const kGPXMimeType = "application/gpx+xml"; @@ -809,7 +809,7 @@ void BookmarkManager::UpdateElevationMyPosition(kml::TrackId const & trackId) double myPositionDistance = TrackSelectionMark::kInvalidDistance; if (m_myPositionMark->HasPosition()) { - double const kEps = 1e-5; + double constexpr kEps = 1e-5; if (m_lastElevationMyPosition.EqualDxDy(m_myPositionMark->GetPivot(), kEps)) return; m_lastElevationMyPosition = m_myPositionMark->GetPivot(); @@ -833,7 +833,7 @@ void BookmarkManager::UpdateElevationMyPosition(kml::TrackId const & trackId) auto es = GetEditSession(); auto trackSelectionMark = GetMarkForEdit(markId); - double const kEpsMeters = 1e-2; + double constexpr kEpsMeters = 1e-2; if (!AlmostEqualAbs(trackSelectionMark->GetMyPositionDistance(), myPositionDistance, kEpsMeters)) { trackSelectionMark->SetMyPositionDistance(myPositionDistance); diff --git a/libs/map/extrapolation_benchmark/extrapolation_benchmark.cpp b/libs/map/extrapolation_benchmark/extrapolation_benchmark.cpp index 1e5b1c36a..7119764ab 100644 --- a/libs/map/extrapolation_benchmark/extrapolation_benchmark.cpp +++ b/libs/map/extrapolation_benchmark/extrapolation_benchmark.cpp @@ -256,7 +256,7 @@ int main(int argc, char * argv[]) GpsInfo const extrapolated = LinearExtrapolation(info1, info2, timeMs); m2::PointD const extrapolatedMerc = mercator::FromLatLon(extrapolated.m_latitude, extrapolated.m_longitude); - double const kHalfSquareSide = 100.0; + double constexpr kHalfSquareSide = 100.0; // |kHalfSquareSide| is chosen based on maximum value of GpsInfo::m_horizontalAccuracy // which is used calculation of projection in production code. m2::RectD const posSquare = diff --git a/libs/map/framework.cpp b/libs/map/framework.cpp index 6783a5bc7..7bc3e5136 100644 --- a/libs/map/framework.cpp +++ b/libs/map/framework.cpp @@ -112,7 +112,7 @@ size_t constexpr kMaxTrafficCacheSizeBytes = 64 /* Mb */ * 1024 * 1024; // This is temporary solution while we don't have a good filter. bool ParseSetGpsTrackMinAccuracyCommand(string const & query) { - char const kGpsAccuracy[] = "?gpstrackaccuracy:"; + char constexpr kGpsAccuracy[] = "?gpstrackaccuracy:"; if (!query.starts_with(kGpsAccuracy)) return false; diff --git a/libs/map/gps_track_filter.cpp b/libs/map/gps_track_filter.cpp index 16eaec3ed..950ba4e61 100644 --- a/libs/map/gps_track_filter.cpp +++ b/libs/map/gps_track_filter.cpp @@ -11,7 +11,7 @@ namespace { -char const kMinHorizontalAccuracyKey[] = "GpsTrackingMinAccuracy"; +char constexpr kMinHorizontalAccuracyKey[] = "GpsTrackingMinAccuracy"; // Minimal horizontal accuracy is required to skip 'bad' points. // Use 250 meters to allow points from a pure GPS + GPS through wifi. diff --git a/libs/map/gps_tracker.cpp b/libs/map/gps_tracker.cpp index ca7a17fa8..35d9653b8 100644 --- a/libs/map/gps_tracker.cpp +++ b/libs/map/gps_tracker.cpp @@ -14,7 +14,7 @@ using namespace std::chrono; namespace { -char const kEnabledKey[] = "GpsTrackingEnabled"; +char constexpr kEnabledKey[] = "GpsTrackingEnabled"; inline std::string GetFilePath() { diff --git a/libs/map/routing_manager.cpp b/libs/map/routing_manager.cpp index 65c2753e0..5507debd4 100644 --- a/libs/map/routing_manager.cpp +++ b/libs/map/routing_manager.cpp @@ -44,9 +44,9 @@ using namespace std; namespace { -char const kRouterTypeKey[] = "router"; +char constexpr kRouterTypeKey[] = "router"; -double const kRouteScaleMultiplier = 1.5; +double constexpr kRouteScaleMultiplier = 1.5; string const kRoutePointsFile = "route_points.dat"; diff --git a/libs/map/routing_mark.cpp b/libs/map/routing_mark.cpp index 594975d74..f96c606e4 100644 --- a/libs/map/routing_mark.cpp +++ b/libs/map/routing_mark.cpp @@ -19,10 +19,10 @@ static std::string const kTransitMarkPrimaryTextOutline = "TransitMarkPrimaryTex static std::string const kTransitMarkSecondaryText = "TransitMarkSecondaryText"; static std::string const kTransitMarkSecondaryTextOutline = "TransitMarkSecondaryTextOutline"; -float const kRouteMarkPrimaryTextSize = 10.5f; -float const kRouteMarkSecondaryTextSize = 10.0f; -float const kRouteMarkSecondaryOffsetY = 2.0f; -float const kTransitMarkTextSize = 12.0f; +float constexpr kRouteMarkPrimaryTextSize = 10.5f; +float constexpr kRouteMarkSecondaryTextSize = 10.0f; +float constexpr kRouteMarkSecondaryOffsetY = 2.0f; +float constexpr kTransitMarkTextSize = 12.0f; static std::string const kSpeedCameraMarkText = "SpeedCameraMarkText"; static std::string const kSpeedCameraMarkBg = "SpeedCameraMarkBg"; diff --git a/libs/map/search_api.cpp b/libs/map/search_api.cpp index 4e1285581..16c4fdde3 100644 --- a/libs/map/search_api.cpp +++ b/libs/map/search_api.cpp @@ -28,7 +28,7 @@ namespace { using BookmarkIdDoc = pair; -double const kDistEqualQueryMeters = 100.0; +double constexpr kDistEqualQueryMeters = 100.0; double const kDistEqualQueryMercator = mercator::MetersToMercator(kDistEqualQueryMeters); // Cancels search query by |handle|. diff --git a/libs/map/search_mark.cpp b/libs/map/search_mark.cpp index db3002543..46bd285ac 100644 --- a/libs/map/search_mark.cpp +++ b/libs/map/search_mark.cpp @@ -85,8 +85,8 @@ namespace { df::ColorConstant const kColorConstant = "SearchmarkDefault"; -float const kVisitedSymbolOpacity = 0.7f; -float const kOutOfFiltersSymbolOpacity = 0.4f; +float constexpr kVisitedSymbolOpacity = 0.7f; +float constexpr kOutOfFiltersSymbolOpacity = 0.4f; std::array const kSymbols = { "search-result", // Default. diff --git a/libs/map/traffic_manager.cpp b/libs/map/traffic_manager.cpp index 3986f7d32..66114e50b 100644 --- a/libs/map/traffic_manager.cpp +++ b/libs/map/traffic_manager.cpp @@ -195,7 +195,7 @@ void TrafficManager::UpdateMyPosition(MyPosition const & myPosition) { // Side of square around |myPosition|. Every mwm which is covered by the square // will get traffic info. - double const kSquareSideM = 5000.0; + double constexpr kSquareSideM = 5000.0; m_currentPosition = {myPosition, true /* initialized */}; if (!IsEnabled() || IsInvalidState() || m_isPaused) diff --git a/libs/map/transit/transit_display.cpp b/libs/map/transit/transit_display.cpp index 320c4edc1..f57e1f006 100644 --- a/libs/map/transit/transit_display.cpp +++ b/libs/map/transit/transit_display.cpp @@ -25,18 +25,18 @@ map const kTransitSymbols = {{TransitType::Subway, "transit namespace { -float const kStopMarkerScale = 2.2f; -float const kTransferMarkerScale = 4.0f; -float const kGateBgScale = 1.2f; +float constexpr kStopMarkerScale = 2.2f; +float constexpr kTransferMarkerScale = 4.0f; +float constexpr kGateBgScale = 1.2f; -int const kSmallIconZoom = 1; -int const kMediumIconZoom = 10; +int constexpr kSmallIconZoom = 1; +int constexpr kMediumIconZoom = 10; -int const kMinStopTitleZoom = 13; +int constexpr kMinStopTitleZoom = 13; -int const kTransferTitleOffset = 2; -int const kStopTitleOffset = 0; -int const kGateTitleOffset = 0; +int constexpr kTransferTitleOffset = 2; +int constexpr kStopTitleOffset = 0; +int constexpr kGateTitleOffset = 0; std::string const kZeroIcon = "zero-icon"; diff --git a/libs/map/transit/transit_reader.cpp b/libs/map/transit/transit_reader.cpp index 49990749f..cdd9bfa8c 100644 --- a/libs/map/transit/transit_reader.cpp +++ b/libs/map/transit/transit_reader.cpp @@ -28,7 +28,7 @@ size_t constexpr kMaxTransitCacheSizeBytes = 5 /* Mb */ * 1024 * 1024; size_t CalculateCacheSize(TransitDisplayInfo const & transitInfo) { - size_t const kSegmentSize = 72; + size_t constexpr kSegmentSize = 72; size_t cacheSize = 0; for (auto const & shape : transitInfo.m_shapesSubway) cacheSize += shape.second.GetPolyline().size() * kSegmentSize; diff --git a/libs/platform/local_country_file_utils.cpp b/libs/platform/local_country_file_utils.cpp index bb0d08dc1..2c23d2bc8 100644 --- a/libs/platform/local_country_file_utils.cpp +++ b/libs/platform/local_country_file_utils.cpp @@ -29,9 +29,9 @@ using std::string; namespace { -char const kBitsExt[] = ".bftsegbits"; -char const kNodesExt[] = ".bftsegnodes"; -char const kOffsetsExt[] = ".offsets"; +char constexpr kBitsExt[] = ".bftsegbits"; +char constexpr kNodesExt[] = ".bftsegnodes"; +char constexpr kOffsetsExt[] = ".offsets"; string GetAdditionalWorldScope() { diff --git a/libs/platform/servers_list.cpp b/libs/platform/servers_list.cpp index ab6dd7901..ac937e7bb 100644 --- a/libs/platform/servers_list.cpp +++ b/libs/platform/servers_list.cpp @@ -14,8 +14,8 @@ namespace downloader std::optional ParseMetaConfig(std::string const & jsonStr) { - char const kSettings[] = "settings"; - char const kServers[] = "servers"; + char constexpr kSettings[] = "settings"; + char constexpr kServers[] = "servers"; MetaConfig outMetaConfig; try diff --git a/libs/routing/car_directions.cpp b/libs/routing/car_directions.cpp index 2642ddc8c..cecced071 100644 --- a/libs/routing/car_directions.cpp +++ b/libs/routing/car_directions.cpp @@ -30,7 +30,7 @@ void FixupCarTurns(vector & routeSegments) // (1) the route enters to the roundabout; // (2) the route leaves the roundabout; uint32_t exitNum = 0; - size_t const kInvalidEnter = numeric_limits::max(); + size_t constexpr kInvalidEnter = numeric_limits::max(); size_t enterRoundAbout = kInvalidEnter; for (size_t idx = 0; idx < routeSegments.size(); ++idx) diff --git a/libs/routing/pedestrian_directions.cpp b/libs/routing/pedestrian_directions.cpp index 23ff6e1b0..3264242f6 100644 --- a/libs/routing/pedestrian_directions.cpp +++ b/libs/routing/pedestrian_directions.cpp @@ -86,7 +86,7 @@ size_t PedestrianDirectionsEngine::GetTurnDirection(IRoutingResult const & resul void PedestrianDirectionsEngine::FixupTurns(vector & routeSegments) { - double const kMergeDistMeters = 15.0; + double constexpr kMergeDistMeters = 15.0; for (size_t idx = 0; idx < routeSegments.size(); ++idx) { diff --git a/libs/routing/restrictions_serialization.hpp b/libs/routing/restrictions_serialization.hpp index 196e4b0be..1a49843a3 100644 --- a/libs/routing/restrictions_serialization.hpp +++ b/libs/routing/restrictions_serialization.hpp @@ -159,7 +159,7 @@ public: } private: - static uint32_t const kDefaultFeatureId = 0; + static uint32_t constexpr kDefaultFeatureId = 0; /// \brief Serializes a range of restrictions form |begin| to |end| to |sink|. /// \param begin is an iterator to the first item to serialize. diff --git a/libs/routing/speed_camera_prohibition.cpp b/libs/routing/speed_camera_prohibition.cpp index f7f091696..3927185cc 100644 --- a/libs/routing/speed_camera_prohibition.cpp +++ b/libs/routing/speed_camera_prohibition.cpp @@ -7,8 +7,10 @@ namespace { +using CountrySetT = std::unordered_set; + // List of country names where mwm should be generated without speed cameras. -std::vector kSpeedCamerasProhibitedCountries = { +CountrySetT kSpeedCamerasProhibitedCountries = { "Germany", "Macedonia", "Switzerland", @@ -17,11 +19,11 @@ std::vector kSpeedCamerasProhibitedCountries = { }; // List of country names where an end user should be warned about speed cameras. -std::vector kSpeedCamerasPartlyProhibitedCountries = { +CountrySetT kSpeedCamerasPartlyProhibitedCountries = { "France", }; -bool IsMwmContained(platform::CountryFile const & mwm, std::vector const & countryList) +bool IsMwmContained(platform::CountryFile const & mwm, CountrySetT const & countryList) { return std::any_of(countryList.cbegin(), countryList.cend(), [&mwm](auto const & country) { return mwm.GetName().starts_with(country); }); diff --git a/libs/routing/speed_camera_prohibition.hpp b/libs/routing/speed_camera_prohibition.hpp index 92a208907..83206afd8 100644 --- a/libs/routing/speed_camera_prohibition.hpp +++ b/libs/routing/speed_camera_prohibition.hpp @@ -4,7 +4,7 @@ namespace routing { -std::string const kDebugSpeedCamSetting = "DebugSpeedCam"; +std::string_view constexpr kDebugSpeedCamSetting = "DebugSpeedCam"; /// \returns true if any information about speed cameras is prohibited in |mwm|. bool AreSpeedCamerasProhibited(platform::CountryFile const & mwm); diff --git a/libs/search/bookmarks/types.cpp b/libs/search/bookmarks/types.cpp index 967c1f169..bc5408326 100644 --- a/libs/search/bookmarks/types.cpp +++ b/libs/search/bookmarks/types.cpp @@ -4,6 +4,6 @@ namespace search { namespace bookmarks { -GroupId const kInvalidGroupId = std::numeric_limits::max(); +GroupId constexpr kInvalidGroupId = std::numeric_limits::max(); } // namespace bookmarks } // namespace search diff --git a/libs/search/cbv.cpp b/libs/search/cbv.cpp index 8a36c0c0b..3bb081224 100644 --- a/libs/search/cbv.cpp +++ b/libs/search/cbv.cpp @@ -9,7 +9,7 @@ namespace search { namespace { -uint64_t const kModulo = 18446744073709551557LLU; +uint64_t constexpr kModulo = 18446744073709551557LLU; } // namespace // static diff --git a/libs/search/editor_delegate.cpp b/libs/search/editor_delegate.cpp index fb86969a1..b33e47836 100644 --- a/libs/search/editor_delegate.cpp +++ b/libs/search/editor_delegate.cpp @@ -38,7 +38,7 @@ string EditorDelegate::GetOriginalFeatureStreet(FeatureID const & fid) const void EditorDelegate::ForEachFeatureAtPoint(osm::Editor::FeatureTypeFn && fn, m2::PointD const & point) const { - auto const kToleranceMeters = 1e-2; + auto constexpr kToleranceMeters = 1e-2; indexer::ForEachFeatureAtPoint(m_dataSource, std::move(fn), point, kToleranceMeters); } } // namespace search diff --git a/libs/search/features_layer_matcher.hpp b/libs/search/features_layer_matcher.hpp index 5a164205c..c73352e44 100644 --- a/libs/search/features_layer_matcher.hpp +++ b/libs/search/features_layer_matcher.hpp @@ -53,7 +53,7 @@ namespace search class FeaturesLayerMatcher { public: - static uint32_t const kInvalidId = std::numeric_limits::max(); + static uint32_t constexpr kInvalidId = std::numeric_limits::max(); static int constexpr kBuildingRadiusMeters = 50; static int constexpr kComplexPoiRadiusMeters = 300; static int constexpr kStreetRadiusMeters = 100; diff --git a/libs/search/geocoder.cpp b/libs/search/geocoder.cpp index 331f7c8fa..147e6f501 100644 --- a/libs/search/geocoder.cpp +++ b/libs/search/geocoder.cpp @@ -1429,7 +1429,7 @@ void Geocoder::MatchPOIsAndBuildings(BaseContext & ctx, size_t curToken, CBV con // Clusters of features by search type. Each cluster is a sorted // list of ids. - size_t const kNumClusters = Model::TYPE_BUILDING + 1; + size_t constexpr kNumClusters = Model::TYPE_BUILDING + 1; vector clusters[kNumClusters]; // Appends |featureId| to the end of the corresponding cluster, if diff --git a/libs/search/intermediate_result.cpp b/libs/search/intermediate_result.cpp index cdedcfb7b..bd87c447a 100644 --- a/libs/search/intermediate_result.cpp +++ b/libs/search/intermediate_result.cpp @@ -28,7 +28,7 @@ namespace { class SkipRegionInfo { - static size_t const kCount = 2; + static size_t constexpr kCount = 2; uint32_t m_types[kCount]; public: diff --git a/libs/search/locality_finder.cpp b/libs/search/locality_finder.cpp index 404bc0f2a..48b5578b6 100644 --- a/libs/search/locality_finder.cpp +++ b/libs/search/locality_finder.cpp @@ -20,8 +20,8 @@ using namespace std; namespace { -double const kMaxCityRadiusMeters = 30000.0; -double const kMaxVillageRadiusMeters = 2000.0; +double constexpr kMaxCityRadiusMeters = 30000.0; +double constexpr kMaxVillageRadiusMeters = 2000.0; struct Filter { @@ -126,7 +126,7 @@ int GetVillagesScale() // Needed for backward compatibility. |kCompatibilityVillagesMinDrawableScale| should be set to // maximal value we have in mwms over all data versions. - int const kCompatibilityVillagesMinDrawableScale = 13; + int constexpr kCompatibilityVillagesMinDrawableScale = 13; ASSERT_LESS_OR_EQUAL(currentVillagesMinDrawableScale, kCompatibilityVillagesMinDrawableScale, ("Set kCompatibilityVillagesMinDrawableScale to", currentVillagesMinDrawableScale)); return max(currentVillagesMinDrawableScale, kCompatibilityVillagesMinDrawableScale); diff --git a/libs/search/locality_scorer.cpp b/libs/search/locality_scorer.cpp index 997f1cad8..48fe41a7a 100644 --- a/libs/search/locality_scorer.cpp +++ b/libs/search/locality_scorer.cpp @@ -307,7 +307,7 @@ void LocalityScorer::GetDocVecs(uint32_t localityId, vector & dvs) const double LocalityScorer::GetSimilarity(QueryVec & qv, IdfMap & docIdfs, vector & dvc) const { - double const kScale = 1e6; + double constexpr kScale = 1e6; double similarity = 0; for (auto & dv : dvc) diff --git a/libs/search/nested_rects_cache.cpp b/libs/search/nested_rects_cache.cpp index 5793cb685..c24babe21 100644 --- a/libs/search/nested_rects_cache.cpp +++ b/libs/search/nested_rects_cache.cpp @@ -16,7 +16,7 @@ namespace search { namespace { -double const kPositionToleranceMeters = 15.0; +double constexpr kPositionToleranceMeters = 15.0; } // namespace NestedRectsCache::NestedRectsCache(DataSource const & dataSource) diff --git a/libs/search/postcode_points.cpp b/libs/search/postcode_points.cpp index 5ea9569b6..3b6a9d4af 100644 --- a/libs/search/postcode_points.cpp +++ b/libs/search/postcode_points.cpp @@ -49,7 +49,7 @@ PostcodePoints::PostcodePoints(MwmValue const & value) m_points = CentersTable::LoadV1(*m_pointsSubReader); CHECK(m_points, ()); - auto const kPostcodeRadiusMultiplier = 5.0; + auto constexpr kPostcodeRadiusMultiplier = 5.0; auto const area = value.GetHeader().GetBounds().Area(); auto const count = static_cast(m_points->Count()); CHECK_NOT_EQUAL(count, 0.0, ("Zero postcodes should not be serialized to", POSTCODE_POINTS_FILE_TAG, "section")); diff --git a/libs/search/processor.cpp b/libs/search/processor.cpp index b0273f097..f9b4c3bb4 100644 --- a/libs/search/processor.cpp +++ b/libs/search/processor.cpp @@ -143,7 +143,7 @@ bool EatVersion(string & s, uint32_t & version) return true; } - size_t const kVersionLength = 6; + size_t constexpr kVersionLength = 6; if (s.size() >= kVersionLength && all_of(s.begin(), s.begin() + kVersionLength, ::isdigit) && (s.size() == kVersionLength || !isdigit(s[kVersionLength + 1]))) { diff --git a/libs/search/search_trie.hpp b/libs/search/search_trie.hpp index f53ca9069..d5468de4c 100644 --- a/libs/search/search_trie.hpp +++ b/libs/search/search_trie.hpp @@ -4,6 +4,6 @@ namespace search { -static uint8_t const kCategoriesLang = 128; -static uint8_t const kPostcodesLang = 129; +static uint8_t constexpr kCategoriesLang = 128; +static uint8_t constexpr kPostcodesLang = 129; } // namespace search diff --git a/libs/storage/country_info_getter.cpp b/libs/storage/country_info_getter.cpp index 99a5f3fc0..651952e9c 100644 --- a/libs/storage/country_info_getter.cpp +++ b/libs/storage/country_info_getter.cpp @@ -22,7 +22,7 @@ namespace storage { namespace { -size_t const kInvalidId = std::numeric_limits::max(); +size_t constexpr kInvalidId = std::numeric_limits::max(); } // namespace // CountryInfoGetterBase --------------------------------------------------------------------------- diff --git a/libs/storage/diff_scheme/diff_scheme_loader.cpp b/libs/storage/diff_scheme/diff_scheme_loader.cpp index 21077193a..fcccd96fd 100644 --- a/libs/storage/diff_scheme/diff_scheme_loader.cpp +++ b/libs/storage/diff_scheme/diff_scheme_loader.cpp @@ -21,13 +21,13 @@ namespace { using namespace storage::diffs; -char const kMaxVersionKey[] = "max_version"; -char const kMwmsKey[] = "mwms"; -char const kNameKey[] = "name"; -char const kSizeKey[] = "size"; -char const kVersionKey[] = "version"; +char constexpr kMaxVersionKey[] = "max_version"; +char constexpr kMwmsKey[] = "mwms"; +char constexpr kNameKey[] = "name"; +char constexpr kSizeKey[] = "size"; +char constexpr kVersionKey[] = "version"; -auto const kTimeoutInSeconds = 5.0; +auto constexpr kTimeoutInSeconds = 5.0; string SerializeCheckerData(LocalMapsInfo const & info) { diff --git a/libs/storage/storage.cpp b/libs/storage/storage.cpp index 68dea01ea..665d3df53 100644 --- a/libs/storage/storage.cpp +++ b/libs/storage/storage.cpp @@ -47,10 +47,10 @@ string const kDownloadQueueKey = "DownloadQueue"; // is most likely already fixed on OSM. Not limited to the latest one or two versions, // because a user can forget to update maps after a new app version has been installed // automatically in the background. -uint64_t const kMaxSecondsTillLastVersionUpdate = 3600 * 24 * 31 * 3; +uint64_t constexpr kMaxSecondsTillLastVersionUpdate = 3600 * 24 * 31 * 3; // Editing maps older than approximately six months old is disabled, because the device // may have been offline for a long time. -uint64_t const kMaxSecondsTillNoEdits = 3600 * 24 * 31 * 6; +uint64_t constexpr kMaxSecondsTillNoEdits = 3600 * 24 * 31 * 6; void DeleteCountryIndexes(LocalCountryFile const & localFile) { diff --git a/libs/traffic/speed_groups.cpp b/libs/traffic/speed_groups.cpp index 191a747df..88e079bcd 100644 --- a/libs/traffic/speed_groups.cpp +++ b/libs/traffic/speed_groups.cpp @@ -4,7 +4,7 @@ namespace traffic { -uint32_t const kSpeedGroupThresholdPercentage[] = {8, 16, 33, 58, 83, 100, 100, 100}; +uint32_t constexpr kSpeedGroupThresholdPercentage[] = {8, 16, 33, 58, 83, 100, 100, 100}; SpeedGroup GetSpeedGroupByPercentage(double p) { diff --git a/libs/traffic/traffic_info.cpp b/libs/traffic/traffic_info.cpp index e4a339b2e..ce218c896 100644 --- a/libs/traffic/traffic_info.cpp +++ b/libs/traffic/traffic_info.cpp @@ -73,7 +73,7 @@ string MakeRemoteURL(string const & name, uint64_t version) return ss.str(); } -char const kETag[] = "etag"; +char constexpr kETag[] = "etag"; } // namespace // TrafficInfo::RoadSegmentId -----------------------------------------------------------------