[core] Fix bugprone-too-small-loop-variable errors

As reported by clang-tidy-8.
This commit is contained in:
Thiago Marcos P. Santos
2020-03-27 18:20:33 +02:00
parent 31338c5d88
commit b4e9c0bd11
7 changed files with 10 additions and 8 deletions

View File

@@ -157,7 +157,7 @@ struct ToValue {
v8::Local<v8::Value> operator()(const std::vector<Value>& array) {
Nan::EscapableHandleScope scope;
v8::Local<v8::Array> result = Nan::New<v8::Array>();
for (unsigned int i = 0; i < array.size(); i++) {
for (std::size_t i = 0; i < array.size(); i++) {
result->Set(i, toJS(array[i]));
}
return scope.Escape(result);

View File

@@ -112,7 +112,7 @@ struct ToValue {
v8::Local<v8::Value> operator()(const std::vector<mbgl::Value>& array) {
Nan::EscapableHandleScope scope;
v8::Local<v8::Array> result = Nan::New<v8::Array>();
for (unsigned int i = 0; i < array.size(); i++) {
for (std::size_t i = 0; i < array.size(); i++) {
result->Set(i, toJS(array[i]));
}
return scope.Escape(result);

View File

@@ -1374,7 +1374,7 @@ void NodeMap::QueryRenderedFeatures(const Nan::FunctionCallbackInfo<v8::Value>&
}
auto array = Nan::New<v8::Array>();
for (unsigned int i = 0; i < optional.size(); i++) {
for (std::size_t i = 0; i < optional.size(); i++) {
array->Set(i, toJS(optional[i]));
}
info.GetReturnValue().Set(array);

View File

@@ -12,6 +12,8 @@ void VertexArray::bind(Context& context,
state->indexBuffer = indexBuffer.getResource<gl::IndexBufferResource>().buffer;
state->bindings.reserve(bindings.size());
// NOLINTNEXTLINE(bugprone-too-small-loop-variable)
for (AttributeLocation location = 0; location < bindings.size(); ++location) {
if (state->bindings.size() <= location) {
state->bindings.emplace_back(context, AttributeLocation(location));

View File

@@ -80,7 +80,7 @@ void FillBucket::addFeature(const GeometryTileFeature& feature,
vertices.emplace_back(FillProgram::layoutVertex(ring[0]));
lines.emplace_back(lineIndex + nVertices - 1, lineIndex);
for (uint32_t i = 1; i < nVertices; i++) {
for (std::size_t i = 1; i < nVertices; i++) {
vertices.emplace_back(FillProgram::layoutVertex(ring[i]));
lines.emplace_back(lineIndex + i - 1, lineIndex + i);
}
@@ -102,7 +102,7 @@ void FillBucket::addFeature(const GeometryTileFeature& feature,
assert(triangleSegment.vertexLength <= std::numeric_limits<uint16_t>::max());
uint16_t triangleIndex = triangleSegment.vertexLength;
for (uint32_t i = 0; i < nIndicies; i += 3) {
for (std::size_t i = 0; i < nIndicies; i += 3) {
triangles.emplace_back(triangleIndex + indices[i],
triangleIndex + indices[i + 1],
triangleIndex + indices[i + 2]);

View File

@@ -96,7 +96,7 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
std::size_t edgeDistance = 0;
for (uint32_t i = 0; i < nVertices; i++) {
for (std::size_t i = 0; i < nVertices; i++) {
const auto& p1 = ring[i];
vertices.emplace_back(
@@ -147,7 +147,7 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
std::size_t nIndices = indices.size();
assert(nIndices % 3 == 0);
for (uint32_t i = 0; i < nIndices; i += 3) {
for (std::size_t i = 0; i < nIndices; i += 3) {
// Counter-Clockwise winding order.
triangles.emplace_back(flatIndices[indices[i]], flatIndices[indices[i + 2]],
flatIndices[indices[i + 1]]);

View File

@@ -305,7 +305,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
bool sourceNeedsRendering = false;
bool sourceNeedsRelayout = false;
for (uint32_t index = 0u; index < orderedLayers.size(); ++index) {
for (std::size_t index = 0; index < orderedLayers.size(); ++index) {
RenderLayer& layer = orderedLayers[index];
const auto* layerInfo = layer.baseImpl->getTypeInfo();
const bool layerIsVisible = layer.baseImpl->visibility != style::VisibilityType::None;