diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-05-10 18:51:04 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-05-12 18:07:36 +0300 |
commit | fa36110dfbdc05b511a3f85461eaca4a29e446a1 (patch) | |
tree | 284bd9a9eca229c026e531bbce1a9f0dd6ba089d /src/mbgl | |
parent | f709d7b0557d3e6d652d9b7d8380f1380962a327 (diff) | |
download | qtlocation-mapboxgl-fa36110dfbdc05b511a3f85461eaca4a29e446a1.tar.gz |
[tidy] modernize-use-auto
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/annotation/fill_annotation_impl.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/annotation/line_annotation_impl.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/gl/context.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/line_bucket.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/class_dictionary.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/function/identity_stops.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/style.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/style/tile_source_impl.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/text/collision_feature.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/text/get_anchors.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/text/quads.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/tile/vector_tile.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/util/intersection_tests.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/util/thread_local.hpp | 2 |
14 files changed, 23 insertions, 23 deletions
diff --git a/src/mbgl/annotation/fill_annotation_impl.cpp b/src/mbgl/annotation/fill_annotation_impl.cpp index 3e91524e86..484870c45c 100644 --- a/src/mbgl/annotation/fill_annotation_impl.cpp +++ b/src/mbgl/annotation/fill_annotation_impl.cpp @@ -21,7 +21,7 @@ void FillAnnotationImpl::updateStyle(Style& style) const { layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID); } - FillLayer* fillLayer = layer->as<FillLayer>(); + auto* fillLayer = layer->as<FillLayer>(); fillLayer->setFillOpacity(annotation.opacity); fillLayer->setFillColor(annotation.color); fillLayer->setFillOutlineColor(annotation.outlineColor); diff --git a/src/mbgl/annotation/line_annotation_impl.cpp b/src/mbgl/annotation/line_annotation_impl.cpp index 15fa2c67f3..65379c42a8 100644 --- a/src/mbgl/annotation/line_annotation_impl.cpp +++ b/src/mbgl/annotation/line_annotation_impl.cpp @@ -22,7 +22,7 @@ void LineAnnotationImpl::updateStyle(Style& style) const { layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID); } - LineLayer* lineLayer = layer->as<LineLayer>(); + auto* lineLayer = layer->as<LineLayer>(); lineLayer->setLineOpacity(annotation.opacity); lineLayer->setLineWidth(annotation.width); lineLayer->setLineColor(annotation.color); diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 3ab1260d27..6a68c3ff69 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -45,7 +45,7 @@ Context::~Context() { } void Context::initializeExtensions(const std::function<gl::ProcAddress(const char*)>& getProcAddress) { - if (const char* extensions = + if (const auto* extensions = reinterpret_cast<const char*>(MBGL_CHECK_ERROR(glGetString(GL_EXTENSIONS)))) { auto fn = [&]( @@ -94,7 +94,7 @@ UniqueShader Context::createShader(ShaderType type, const std::string& source) { UniqueShader result { MBGL_CHECK_ERROR(glCreateShader(static_cast<GLenum>(type))), { this } }; const GLchar* sources = source.data(); - const GLsizei lengths = static_cast<GLsizei>(source.length()); + const auto lengths = static_cast<GLsizei>(source.length()); MBGL_CHECK_ERROR(glShaderSource(result, 1, &sources, &lengths)); MBGL_CHECK_ERROR(glCompileShader(result)); diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index 7bb4e2f202..f322ba4614 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -183,7 +183,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates, FeatureType const bool isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevCoordinate && nextCoordinate; if (isSharpCorner && i > first) { - const double prevSegmentLength = util::dist<double>(*currentCoordinate, *prevCoordinate); + const auto prevSegmentLength = util::dist<double>(*currentCoordinate, *prevCoordinate); if (prevSegmentLength > 2.0 * sharpCornerOffset) { GeometryCoordinate newPrevVertex = *currentCoordinate - convertPoint<int16_t>(util::round(convertPoint<double>(*currentCoordinate - *prevCoordinate) * (sharpCornerOffset / prevSegmentLength))); distance += util::dist<double>(newPrevVertex, *prevCoordinate); @@ -356,7 +356,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates, FeatureType } if (isSharpCorner && i < len - 1) { - const double nextSegmentLength = util::dist<double>(*currentCoordinate, *nextCoordinate); + const auto nextSegmentLength = util::dist<double>(*currentCoordinate, *nextCoordinate); if (nextSegmentLength > 2 * sharpCornerOffset) { GeometryCoordinate newCurrentVertex = *currentCoordinate + convertPoint<int16_t>(util::round(convertPoint<double>(*nextCoordinate - *currentCoordinate) * (sharpCornerOffset / nextSegmentLength))); distance += util::dist<double>(newCurrentVertex, *currentCoordinate); diff --git a/src/mbgl/style/class_dictionary.cpp b/src/mbgl/style/class_dictionary.cpp index ec06ee7d9d..6860044dbd 100644 --- a/src/mbgl/style/class_dictionary.cpp +++ b/src/mbgl/style/class_dictionary.cpp @@ -18,7 +18,7 @@ ClassDictionary &ClassDictionary::Get() { }); }); - ClassDictionary *ptr = reinterpret_cast<ClassDictionary *>(pthread_getspecific(store_key)); + auto *ptr = reinterpret_cast<ClassDictionary *>(pthread_getspecific(store_key)); if (ptr == nullptr) { ptr = new ClassDictionary(); pthread_setspecific(store_key, ptr); @@ -31,7 +31,7 @@ ClassID ClassDictionary::lookup(const std::string &class_name) { auto it = store.find(class_name); if (it == store.end()) { // Insert the class name into the store. - ClassID id = ClassID(uint32_t(ClassID::Named) + offset++); + auto id = ClassID(uint32_t(ClassID::Named) + offset++); store.emplace(class_name, id); return id; } else { diff --git a/src/mbgl/style/function/identity_stops.cpp b/src/mbgl/style/function/identity_stops.cpp index 4c9d01d086..0c6891eac5 100644 --- a/src/mbgl/style/function/identity_stops.cpp +++ b/src/mbgl/style/function/identity_stops.cpp @@ -46,7 +46,7 @@ optional<std::array<float, 2>> IdentityStops<std::array<float, 2>>::evaluate(con return {}; } - const std::vector<Value>& vector = value.get<std::vector<Value>>(); + const auto& vector = value.get<std::vector<Value>>(); if (vector.size() != 2 || !numericValue<float>(vector[0]) || !numericValue<float>(vector[1])) { return {}; } diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index f083ca47b8..97d30b2494 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -87,7 +87,7 @@ Style::~Style() { } for (const auto& layer : layers) { - if (CustomLayer* customLayer = layer->as<CustomLayer>()) { + if (auto* customLayer = layer->as<CustomLayer>()) { customLayer->impl->deinitialize(); } } @@ -258,7 +258,7 @@ Layer* Style::addLayer(std::unique_ptr<Layer> layer, optional<std::string> befor throw std::runtime_error(std::string{"Layer "} + layer->getID() + " already exists"); } - if (CustomLayer* customLayer = layer->as<CustomLayer>()) { + if (auto* customLayer = layer->as<CustomLayer>()) { customLayer->impl->initialize(); } @@ -280,7 +280,7 @@ std::unique_ptr<Layer> Style::removeLayer(const std::string& id) { auto layer = std::move(*it); - if (CustomLayer* customLayer = layer->as<CustomLayer>()) { + if (auto* customLayer = layer->as<CustomLayer>()) { customLayer->impl->deinitialize(); } diff --git a/src/mbgl/style/tile_source_impl.cpp b/src/mbgl/style/tile_source_impl.cpp index d2ce3def9f..4d47221da9 100644 --- a/src/mbgl/style/tile_source_impl.cpp +++ b/src/mbgl/style/tile_source_impl.cpp @@ -29,7 +29,7 @@ void TileSourceImpl::loadDescription(FileSource& fileSource) { return; } - const std::string& url = urlOrTileset.get<std::string>(); + const auto& url = urlOrTileset.get<std::string>(); req = fileSource.request(Resource::source(url), [this, url](Response res) { if (res.error) { observer->onSourceError(base, std::make_exception_ptr(std::runtime_error(res.error->message))); diff --git a/src/mbgl/text/collision_feature.cpp b/src/mbgl/text/collision_feature.cpp index 885ba5c426..71d7cc74e0 100644 --- a/src/mbgl/text/collision_feature.cpp +++ b/src/mbgl/text/collision_feature.cpp @@ -71,7 +71,7 @@ void CollisionFeature::bboxifyLabel(const GeometryCoordinates& line, GeometryCoo p = line[index]; } while (anchorDistance > -labelLength / 2); - float segmentLength = util::dist<float>(line[index], line[index + 1]); + auto segmentLength = util::dist<float>(line[index], line[index + 1]); for (unsigned int i = 0; i < nBoxes; i++) { // the distance the box will be from the anchor diff --git a/src/mbgl/text/get_anchors.cpp b/src/mbgl/text/get_anchors.cpp index 82702b20f0..d41faf2a71 100644 --- a/src/mbgl/text/get_anchors.cpp +++ b/src/mbgl/text/get_anchors.cpp @@ -34,7 +34,7 @@ static Anchors resample(const GeometryCoordinates& line, const GeometryCoordinate& a = *(it); const GeometryCoordinate& b = *(it + 1); - const float segmentDist = util::dist<float>(a, b); + const auto segmentDist = util::dist<float>(a, b); const float angle = util::angle_to(b, a); while (markedDistance + spacing < distance + segmentDist) { diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index e1a9699835..02236b1b89 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -177,7 +177,7 @@ inline Point<float> getVirtualSegmentAnchor(const Point<float>& segmentBegin, co inline float getMinScaleForSegment(const float glyphDistanceFromAnchor, const Point<float>& segmentAnchor, const Point<float>& segmentEnd) { - const float distanceFromAnchorToEnd = util::dist<float>(segmentAnchor, segmentEnd); + const auto distanceFromAnchorToEnd = util::dist<float>(segmentAnchor, segmentEnd); return glyphDistanceFromAnchor / distanceFromAnchorToEnd; } diff --git a/src/mbgl/tile/vector_tile.cpp b/src/mbgl/tile/vector_tile.cpp index 46914e5f5a..d22617dd07 100644 --- a/src/mbgl/tile/vector_tile.cpp +++ b/src/mbgl/tile/vector_tile.cpp @@ -162,7 +162,7 @@ optional<Value> VectorTileFeature::getValue(const std::string& key) const { auto start_itr = tags_iter.begin(); const auto & end_itr = tags_iter.end(); while (start_itr != end_itr) { - uint32_t tag_key = static_cast<uint32_t>(*start_itr++); + auto tag_key = static_cast<uint32_t>(*start_itr++); if (layerData->keysMap.size() <= tag_key) { throw std::runtime_error("feature referenced out of range key"); @@ -172,7 +172,7 @@ optional<Value> VectorTileFeature::getValue(const std::string& key) const { throw std::runtime_error("uneven number of feature tag ids"); } - uint32_t tag_val = static_cast<uint32_t>(*start_itr++);; + auto tag_val = static_cast<uint32_t>(*start_itr++);; if (layerData->values.size() <= tag_val) { throw std::runtime_error("feature referenced out of range value"); } @@ -190,11 +190,11 @@ std::unordered_map<std::string,Value> VectorTileFeature::getProperties() const { auto start_itr = tags_iter.begin(); const auto & end_itr = tags_iter.end(); while (start_itr != end_itr) { - uint32_t tag_key = static_cast<uint32_t>(*start_itr++); + auto tag_key = static_cast<uint32_t>(*start_itr++); if (start_itr == end_itr) { throw std::runtime_error("uneven number of feature tag ids"); } - uint32_t tag_val = static_cast<uint32_t>(*start_itr++); + auto tag_val = static_cast<uint32_t>(*start_itr++); properties[layerData->keys.at(tag_key)] = layerData->values.at(tag_val); } return properties; @@ -219,7 +219,7 @@ GeometryCollection VectorTileFeature::getGeometries() const { auto g_itr = geometry_iter.begin(); while (g_itr != geometry_iter.end()) { if (length == 0) { - uint32_t cmd_length = static_cast<uint32_t>(*g_itr++); + auto cmd_length = static_cast<uint32_t>(*g_itr++); cmd = cmd_length & 0x7; length = cmd_length >> 3; } diff --git a/src/mbgl/util/intersection_tests.cpp b/src/mbgl/util/intersection_tests.cpp index c580357298..e6ce245c0e 100644 --- a/src/mbgl/util/intersection_tests.cpp +++ b/src/mbgl/util/intersection_tests.cpp @@ -19,7 +19,7 @@ bool polygonContainsPoint(const GeometryCoordinates& ring, const GeometryCoordin // Code from http://stackoverflow.com/a/1501725/331379. float distToSegmentSquared(const GeometryCoordinate& p, const GeometryCoordinate& v, const GeometryCoordinate& w) { if (v == w) return util::distSqr<float>(p, v); - const float l2 = util::distSqr<float>(v, w); + const auto l2 = util::distSqr<float>(v, w); const float t = float((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2; if (t < 0) return util::distSqr<float>(p, v); if (t > 1) return util::distSqr<float>(p, w); diff --git a/src/mbgl/util/thread_local.hpp b/src/mbgl/util/thread_local.hpp index 9fddbd5bbc..15d4d56524 100644 --- a/src/mbgl/util/thread_local.hpp +++ b/src/mbgl/util/thread_local.hpp @@ -32,7 +32,7 @@ public: } T* get() { - T* ret = reinterpret_cast<T*>(pthread_getspecific(key)); + auto* ret = reinterpret_cast<T*>(pthread_getspecific(key)); if (!ret) { return nullptr; } |