Fix performance-type-promotion-in-math-fn clang-tidy warning (#6908)
This commit is contained in:
parent
163a2cfe3c
commit
1a6f4c44e7
@ -54,7 +54,6 @@ Checks: >
|
||||
performance-*,
|
||||
-performance-noexcept-move-constructor,
|
||||
-performance-no-int-to-ptr,
|
||||
-performance-type-promotion-in-math-fn,
|
||||
readability-*,
|
||||
-readability-avoid-const-params-in-decls,
|
||||
-readability-braces-around-statements,
|
||||
|
@ -443,23 +443,22 @@ class RouteAPI : public BaseAPI
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Speed)
|
||||
{
|
||||
double prev_speed = 0;
|
||||
speed =
|
||||
GetAnnotations<float>(fb_result,
|
||||
leg_geometry,
|
||||
[&prev_speed](const guidance::LegGeometry::Annotation &anno)
|
||||
{
|
||||
if (anno.duration < std::numeric_limits<float>::min())
|
||||
{
|
||||
return prev_speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto speed =
|
||||
round(anno.distance / anno.duration * 10.) / 10.;
|
||||
prev_speed = speed;
|
||||
return util::json::clamp_float(speed);
|
||||
}
|
||||
});
|
||||
speed = GetAnnotations<float>(
|
||||
fb_result,
|
||||
leg_geometry,
|
||||
[&prev_speed](const guidance::LegGeometry::Annotation &anno)
|
||||
{
|
||||
if (anno.duration < std::numeric_limits<float>::min())
|
||||
{
|
||||
return prev_speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto speed = std::round(anno.distance / anno.duration * 10.) / 10.;
|
||||
prev_speed = speed;
|
||||
return util::json::clamp_float(speed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> duration;
|
||||
|
@ -497,13 +497,13 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
||||
{
|
||||
// Calculate the speed for this line
|
||||
std::uint32_t speed_kmh_idx = static_cast<std::uint32_t>(
|
||||
round(length / from_alias<double>(forward_duration) * 10 * 3.6));
|
||||
std::round(length / from_alias<double>(forward_duration) * 10 * 3.6));
|
||||
|
||||
// Rate values are in meters per weight-unit - and similar to speeds, we
|
||||
// present 1 decimal place of precision (these values are added as
|
||||
// double/10) lower down
|
||||
std::uint32_t forward_rate = static_cast<std::uint32_t>(
|
||||
round(length / from_alias<double>(forward_weight) * 10.));
|
||||
std::round(length / from_alias<double>(forward_weight) * 10.));
|
||||
|
||||
auto tile_line = coordinatesToTileLine(a, b, tile_bbox);
|
||||
if (!tile_line.empty())
|
||||
@ -531,13 +531,13 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
||||
{
|
||||
// Calculate the speed for this line
|
||||
std::uint32_t speed_kmh_idx = static_cast<std::uint32_t>(
|
||||
round(length / from_alias<double>(reverse_duration) * 10 * 3.6));
|
||||
std::round(length / from_alias<double>(reverse_duration) * 10 * 3.6));
|
||||
|
||||
// Rate values are in meters per weight-unit - and similar to speeds, we
|
||||
// present 1 decimal place of precision (these values are added as
|
||||
// double/10) lower down
|
||||
std::uint32_t reverse_rate = static_cast<std::uint32_t>(
|
||||
round(length / from_alias<double>(reverse_weight) * 10.));
|
||||
std::round(length / from_alias<double>(reverse_weight) * 10.));
|
||||
|
||||
auto tile_line = coordinatesToTileLine(b, a, tile_bbox);
|
||||
if (!tile_line.empty())
|
||||
|
@ -40,8 +40,8 @@ RasterDatum RasterSource::GetRasterData(const int lon, const int lat) const
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::size_t xth = static_cast<std::size_t>(round((lon - xmin) / xstep));
|
||||
const std::size_t yth = static_cast<std::size_t>(round((ymax - lat) / ystep));
|
||||
const std::size_t xth = static_cast<std::size_t>(std::round((lon - xmin) / xstep));
|
||||
const std::size_t yth = static_cast<std::size_t>(std::round((ymax - lat) / ystep));
|
||||
|
||||
return {raster_data(xth, yth)};
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ void test_route_same_coordinates_fixture(bool use_json_only_api)
|
||||
itr.get<json::Object>().values["hint"] = "";
|
||||
|
||||
// Round value to 6 decimal places for double comparison later
|
||||
itr.get<json::Object>().values["distance"] =
|
||||
round(itr.get<json::Object>().values["distance"].get<json::Number>().value * 1000000);
|
||||
itr.get<json::Object>().values["distance"] = std::round(
|
||||
itr.get<json::Object>().values["distance"].get<json::Number>().value * 1000000);
|
||||
}
|
||||
|
||||
const auto location = json::Array{{{7.437070}, {43.749248}}};
|
||||
@ -65,11 +65,11 @@ void test_route_same_coordinates_fixture(bool use_json_only_api)
|
||||
{"waypoints",
|
||||
json::Array{{json::Object{{{"name", "Boulevard du Larvotto"},
|
||||
{"location", location},
|
||||
{"distance", round(0.137249 * 1000000)},
|
||||
{"distance", std::round(0.137249 * 1000000)},
|
||||
{"hint", ""}}},
|
||||
json::Object{{{"name", "Boulevard du Larvotto"},
|
||||
{"location", location},
|
||||
{"distance", round(0.137249 * 1000000)},
|
||||
{"distance", std::round(0.137249 * 1000000)},
|
||||
{"hint", ""}}}}}},
|
||||
{"routes",
|
||||
json::Array{{json::Object{
|
||||
|
Loading…
Reference in New Issue
Block a user