summaryrefslogtreecommitdiff
path: root/src/mbgl/text/check_max_angle.cpp
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-12-04 14:53:32 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-12-05 19:04:15 +0200
commitc2899f76b68ebaa2bba61e4407e128ab261ab212 (patch)
tree873acb061104f43b2c5e47bb42c209486b8be3a6 /src/mbgl/text/check_max_angle.cpp
parent27536631d01d623bb4a08c3e85f2a62a6d187a12 (diff)
downloadqtlocation-mapboxgl-upstream/alexshalamov_signed_to_unsigned_conversion.tar.gz
[core] Don't use signed int type for anchor segmentupstream/alexshalamov_signed_to_unsigned_conversion
Diffstat (limited to 'src/mbgl/text/check_max_angle.cpp')
-rw-r--r--src/mbgl/text/check_max_angle.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/mbgl/text/check_max_angle.cpp b/src/mbgl/text/check_max_angle.cpp
index 9109235798..0569767634 100644
--- a/src/mbgl/text/check_max_angle.cpp
+++ b/src/mbgl/text/check_max_angle.cpp
@@ -19,20 +19,19 @@ bool checkMaxAngle(const GeometryCoordinates& line,
const float windowSize,
const float maxAngle) {
// horizontal labels always pass
- if (anchor.segment < 0) return true;
+ if (!anchor.segment) return true;
GeometryCoordinate anchorPoint = convertPoint<int16_t>(anchor.point);
GeometryCoordinate &p = anchorPoint;
- int index = anchor.segment + 1;
+ std::size_t index = *anchor.segment + 1;
float anchorDistance = 0;
// move backwards along the line to the first segment the label appears on
while (anchorDistance > -labelLength / 2) {
- index--;
-
// there isn't enough room for the label after the beginning of the line
- if (index < 0) return false;
+ if (index == 0u) return false;
+ index--;
anchorDistance -= util::dist<float>(line[index], p);
p = line[index];
}
@@ -48,7 +47,7 @@ bool checkMaxAngle(const GeometryCoordinates& line,
while (anchorDistance < labelLength / 2) {
// there isn't enough room for the label before the end of the line
- if (index + 1 >= (int)line.size()) return false;
+ if (index + 1 >= line.size()) return false;
auto& prev = line[index - 1];
auto& current = line[index];