From c2899f76b68ebaa2bba61e4407e128ab261ab212 Mon Sep 17 00:00:00 2001 From: Alexander Shalamov Date: Wed, 4 Dec 2019 14:53:32 +0200 Subject: [core] Don't use signed int type for anchor segment --- src/mbgl/text/check_max_angle.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/mbgl/text/check_max_angle.cpp') 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(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(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]; -- cgit v1.2.1