From fa36110dfbdc05b511a3f85461eaca4a29e446a1 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 10 May 2017 18:51:04 +0300 Subject: [tidy] modernize-use-auto --- include/mbgl/style/conversion/property_setter.hpp | 6 +++--- platform/default/async_task.cpp | 2 +- platform/default/image.cpp | 2 +- platform/default/jpeg_reader.cpp | 8 ++++---- platform/default/mbgl/storage/offline_download.cpp | 11 +++++------ platform/default/png_reader.cpp | 2 +- platform/default/sqlite3.cpp | 2 +- platform/default/timer.cpp | 2 +- platform/glfw/glfw_view.cpp | 12 ++++++------ platform/linux/src/headless_backend_glx.cpp | 4 ++-- platform/linux/src/headless_display_glx.cpp | 2 +- src/mbgl/annotation/fill_annotation_impl.cpp | 2 +- src/mbgl/annotation/line_annotation_impl.cpp | 2 +- src/mbgl/gl/context.cpp | 4 ++-- src/mbgl/renderer/line_bucket.cpp | 4 ++-- src/mbgl/style/class_dictionary.cpp | 4 ++-- src/mbgl/style/function/identity_stops.cpp | 2 +- src/mbgl/style/style.cpp | 6 +++--- src/mbgl/style/tile_source_impl.cpp | 2 +- src/mbgl/text/collision_feature.cpp | 2 +- src/mbgl/text/get_anchors.cpp | 2 +- src/mbgl/text/quads.cpp | 2 +- src/mbgl/tile/vector_tile.cpp | 10 +++++----- src/mbgl/util/intersection_tests.cpp | 2 +- src/mbgl/util/thread_local.hpp | 2 +- 25 files changed, 49 insertions(+), 50 deletions(-) diff --git a/include/mbgl/style/conversion/property_setter.hpp b/include/mbgl/style/conversion/property_setter.hpp index 1f537f3c4d..8658fd60b0 100644 --- a/include/mbgl/style/conversion/property_setter.hpp +++ b/include/mbgl/style/conversion/property_setter.hpp @@ -21,7 +21,7 @@ using PaintPropertySetter = optional (*) (Layer&, const V&, const optiona template optional setLayoutProperty(Layer& layer, const V& value) { - L* typedLayer = layer.as(); + auto* typedLayer = layer.as(); if (!typedLayer) { return Error { "layer doesn't support this property" }; } @@ -38,7 +38,7 @@ optional setLayoutProperty(Layer& layer, const V& value) { template &)> optional setPaintProperty(Layer& layer, const V& value, const optional& klass) { - L* typedLayer = layer.as(); + auto* typedLayer = layer.as(); if (!typedLayer) { return Error { "layer doesn't support this property" }; } @@ -55,7 +55,7 @@ optional setPaintProperty(Layer& layer, const V& value, const optional&)> optional setTransition(Layer& layer, const V& value, const optional& klass) { - L* typedLayer = layer.as(); + auto* typedLayer = layer.as(); if (!typedLayer) { return Error { "layer doesn't support this property" }; } diff --git a/platform/default/async_task.cpp b/platform/default/async_task.cpp index 5fa9db8d33..50891056d8 100644 --- a/platform/default/async_task.cpp +++ b/platform/default/async_task.cpp @@ -16,7 +16,7 @@ public: : async(new uv_async_t), task(std::move(fn)) { - uv_loop_t* loop = reinterpret_cast(RunLoop::getLoopHandle()); + auto* loop = reinterpret_cast(RunLoop::getLoopHandle()); if (uv_async_init(loop, async, asyncCallback) != 0) { throw std::runtime_error("Failed to initialize async."); } diff --git a/platform/default/image.cpp b/platform/default/image.cpp index ad9d83a08d..447c6bcd66 100644 --- a/platform/default/image.cpp +++ b/platform/default/image.cpp @@ -12,7 +12,7 @@ PremultipliedImage decodePNG(const uint8_t*, size_t); PremultipliedImage decodeJPEG(const uint8_t*, size_t); PremultipliedImage decodeImage(const std::string& string) { - const uint8_t* data = reinterpret_cast(string.data()); + const auto* data = reinterpret_cast(string.data()); const size_t size = string.size(); #if !defined(__ANDROID__) && !defined(__APPLE__) diff --git a/platform/default/jpeg_reader.cpp b/platform/default/jpeg_reader.cpp index c5e9d880c0..5f613f9423 100644 --- a/platform/default/jpeg_reader.cpp +++ b/platform/default/jpeg_reader.cpp @@ -21,12 +21,12 @@ struct jpeg_stream_wrapper { }; static void init_source(j_decompress_ptr cinfo) { - jpeg_stream_wrapper* wrap = reinterpret_cast(cinfo->src); + auto* wrap = reinterpret_cast(cinfo->src); wrap->stream->seekg(0, std::ios_base::beg); } static boolean fill_input_buffer(j_decompress_ptr cinfo) { - jpeg_stream_wrapper* wrap = reinterpret_cast(cinfo->src); + auto* wrap = reinterpret_cast(cinfo->src); wrap->stream->read(reinterpret_cast(&wrap->buffer[0]), BUF_SIZE); std::streamsize size = wrap->stream->gcount(); wrap->manager.next_input_byte = wrap->buffer.data(); @@ -36,7 +36,7 @@ static boolean fill_input_buffer(j_decompress_ptr cinfo) { static void skip(j_decompress_ptr cinfo, long count) { if (count <= 0) return; // A zero or negative skip count should be treated as a no-op. - jpeg_stream_wrapper* wrap = reinterpret_cast(cinfo->src); + auto* wrap = reinterpret_cast(cinfo->src); if (wrap->manager.bytes_in_buffer > 0 && count < static_cast(wrap->manager.bytes_in_buffer)) { @@ -59,7 +59,7 @@ static void attach_stream(j_decompress_ptr cinfo, std::istream* in) { cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(jpeg_stream_wrapper)); } - jpeg_stream_wrapper * src = reinterpret_cast (cinfo->src); + auto * src = reinterpret_cast (cinfo->src); src->manager.init_source = init_source; src->manager.fill_input_buffer = fill_input_buffer; src->manager.skip_input_data = skip; diff --git a/platform/default/mbgl/storage/offline_download.cpp b/platform/default/mbgl/storage/offline_download.cpp index 901f996a4f..5a487b3534 100644 --- a/platform/default/mbgl/storage/offline_download.cpp +++ b/platform/default/mbgl/storage/offline_download.cpp @@ -76,8 +76,7 @@ OfflineRegionStatus OfflineDownload::getStatus() const { switch (type) { case SourceType::Vector: case SourceType::Raster: { - style::TileSourceImpl* tileSource = - static_cast(source->baseImpl.get()); + auto* tileSource = static_cast(source->baseImpl.get()); const variant& urlOrTileset = tileSource->getURLOrTileset(); const uint16_t tileSize = tileSource->getTileSize(); @@ -86,7 +85,7 @@ OfflineRegionStatus OfflineDownload::getStatus() const { definition.tileCover(type, tileSize, urlOrTileset.get().zoomRange).size(); } else { result.requiredResourceCount += 1; - const std::string& url = urlOrTileset.get(); + const auto& url = urlOrTileset.get(); optional sourceResponse = offlineDatabase.get(Resource::source(url)); if (sourceResponse) { style::conversion::Error error; @@ -103,7 +102,7 @@ OfflineRegionStatus OfflineDownload::getStatus() const { } case SourceType::GeoJSON: { - style::GeoJSONSource* geojsonSource = source->as(); + auto* geojsonSource = source->as(); if (geojsonSource->getURL()) { result.requiredResourceCount += 1; } @@ -151,7 +150,7 @@ void OfflineDownload::activateDownload() { if (urlOrTileset.is()) { queueTiles(type, tileSize, urlOrTileset.get()); } else { - const std::string& url = urlOrTileset.get(); + const auto& url = urlOrTileset.get(); status.requiredResourceCountIsPrecise = false; status.requiredResourceCount++; requiredSourceURLs.insert(url); @@ -174,7 +173,7 @@ void OfflineDownload::activateDownload() { } case SourceType::GeoJSON: { - style::GeoJSONSource::Impl* geojsonSource = + auto* geojsonSource = static_cast(source->baseImpl.get()); if (geojsonSource->getURL()) { diff --git a/platform/default/png_reader.cpp b/platform/default/png_reader.cpp index 29ef3058e1..4d4ee29d1f 100644 --- a/platform/default/png_reader.cpp +++ b/platform/default/png_reader.cpp @@ -40,7 +40,7 @@ static void user_warning_fn(png_structp, png_const_charp warning_msg) { } static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - std::istream* fin = reinterpret_cast(png_get_io_ptr(png_ptr)); + auto* fin = reinterpret_cast(png_get_io_ptr(png_ptr)); fin->read(reinterpret_cast(data), length); std::streamsize read_count = fin->gcount(); if (read_count < 0 || static_cast(read_count) != length) diff --git a/platform/default/sqlite3.cpp b/platform/default/sqlite3.cpp index 304d5e9aba..4cbe1df775 100644 --- a/platform/default/sqlite3.cpp +++ b/platform/default/sqlite3.cpp @@ -314,7 +314,7 @@ template <> std::string Statement::get(int offset) { template <> std::vector Statement::get(int offset) { assert(impl); - const uint8_t* begin = reinterpret_cast(sqlite3_column_blob(impl->stmt, offset)); + const auto* begin = reinterpret_cast(sqlite3_column_blob(impl->stmt, offset)); const uint8_t* end = begin + sqlite3_column_bytes(impl->stmt, offset); return { begin, end }; } diff --git a/platform/default/timer.cpp b/platform/default/timer.cpp index cd0e6da6aa..90a85bfc1f 100644 --- a/platform/default/timer.cpp +++ b/platform/default/timer.cpp @@ -10,7 +10,7 @@ namespace util { class Timer::Impl { public: Impl() : timer(new uv_timer_t) { - uv_loop_t* loop = reinterpret_cast(RunLoop::getLoopHandle()); + auto* loop = reinterpret_cast(RunLoop::getLoopHandle()); if (uv_timer_init(loop, timer) != 0) { throw std::runtime_error("Failed to initialize timer."); } diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 31b0b92c58..1be38e5e4a 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -145,7 +145,7 @@ void GLFWView::bind() { } void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, int mods) { - GLFWView *view = reinterpret_cast(glfwGetWindowUserPointer(window)); + auto *view = reinterpret_cast(glfwGetWindowUserPointer(window)); if (action == GLFW_RELEASE) { switch (key) { @@ -356,7 +356,7 @@ void GLFWView::popAnnotation() { } void GLFWView::onScroll(GLFWwindow *window, double /*xOffset*/, double yOffset) { - GLFWView *view = reinterpret_cast(glfwGetWindowUserPointer(window)); + auto *view = reinterpret_cast(glfwGetWindowUserPointer(window)); double delta = yOffset * 40; bool isWheel = delta != 0 && std::fmod(delta, 4.000244140625) == 0; @@ -378,14 +378,14 @@ void GLFWView::onScroll(GLFWwindow *window, double /*xOffset*/, double yOffset) } void GLFWView::onWindowResize(GLFWwindow *window, int width, int height) { - GLFWView *view = reinterpret_cast(glfwGetWindowUserPointer(window)); + auto *view = reinterpret_cast(glfwGetWindowUserPointer(window)); view->width = width; view->height = height; view->map->setSize({ static_cast(view->width), static_cast(view->height) }); } void GLFWView::onFramebufferResize(GLFWwindow *window, int width, int height) { - GLFWView *view = reinterpret_cast(glfwGetWindowUserPointer(window)); + auto *view = reinterpret_cast(glfwGetWindowUserPointer(window)); view->fbWidth = width; view->fbHeight = height; view->bind(); @@ -398,7 +398,7 @@ void GLFWView::onFramebufferResize(GLFWwindow *window, int width, int height) { } void GLFWView::onMouseClick(GLFWwindow *window, int button, int action, int modifiers) { - GLFWView *view = reinterpret_cast(glfwGetWindowUserPointer(window)); + auto *view = reinterpret_cast(glfwGetWindowUserPointer(window)); if (button == GLFW_MOUSE_BUTTON_RIGHT || (button == GLFW_MOUSE_BUTTON_LEFT && modifiers & GLFW_MOD_CONTROL)) { @@ -426,7 +426,7 @@ void GLFWView::onMouseClick(GLFWwindow *window, int button, int action, int modi } void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) { - GLFWView *view = reinterpret_cast(glfwGetWindowUserPointer(window)); + auto *view = reinterpret_cast(glfwGetWindowUserPointer(window)); if (view->tracking) { double dx = x - view->lastX; double dy = y - view->lastY; diff --git a/platform/linux/src/headless_backend_glx.cpp b/platform/linux/src/headless_backend_glx.cpp index 36a60ec06b..1c1592ac75 100644 --- a/platform/linux/src/headless_backend_glx.cpp +++ b/platform/linux/src/headless_backend_glx.cpp @@ -58,8 +58,8 @@ bool HeadlessBackend::hasDisplay() { void HeadlessBackend::createContext() { assert(!hasContext()); - Display* xDisplay = display->attribute(); - GLXFBConfig* fbConfigs = display->attribute(); + auto* xDisplay = display->attribute(); + auto* fbConfigs = display->attribute(); // Try to create a legacy context. GLXContext glContext = glXCreateNewContext(xDisplay, fbConfigs[0], GLX_RGBA_TYPE, None, True); diff --git a/platform/linux/src/headless_display_glx.cpp b/platform/linux/src/headless_display_glx.cpp index 4275ebb646..963a5234cb 100644 --- a/platform/linux/src/headless_display_glx.cpp +++ b/platform/linux/src/headless_display_glx.cpp @@ -27,7 +27,7 @@ HeadlessDisplay::Impl::Impl() { throw std::runtime_error("Failed to open X display."); } - const char *extensions = reinterpret_cast(glXQueryServerString(xDisplay, DefaultScreen(xDisplay), GLX_EXTENSIONS)); + const auto *extensions = reinterpret_cast(glXQueryServerString(xDisplay, DefaultScreen(xDisplay), GLX_EXTENSIONS)); if (!extensions) { throw std::runtime_error("Cannot read GLX extensions."); } 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(); + auto* fillLayer = layer->as(); 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(); + auto* lineLayer = layer->as(); 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& getProcAddress) { - if (const char* extensions = + if (const auto* extensions = reinterpret_cast(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(type))), { this } }; const GLchar* sources = source.data(); - const GLsizei lengths = static_cast(source.length()); + const auto lengths = static_cast(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(*currentCoordinate, *prevCoordinate); + const auto prevSegmentLength = util::dist(*currentCoordinate, *prevCoordinate); if (prevSegmentLength > 2.0 * sharpCornerOffset) { GeometryCoordinate newPrevVertex = *currentCoordinate - convertPoint(util::round(convertPoint(*currentCoordinate - *prevCoordinate) * (sharpCornerOffset / prevSegmentLength))); distance += util::dist(newPrevVertex, *prevCoordinate); @@ -356,7 +356,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates, FeatureType } if (isSharpCorner && i < len - 1) { - const double nextSegmentLength = util::dist(*currentCoordinate, *nextCoordinate); + const auto nextSegmentLength = util::dist(*currentCoordinate, *nextCoordinate); if (nextSegmentLength > 2 * sharpCornerOffset) { GeometryCoordinate newCurrentVertex = *currentCoordinate + convertPoint(util::round(convertPoint(*nextCoordinate - *currentCoordinate) * (sharpCornerOffset / nextSegmentLength))); distance += util::dist(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(pthread_getspecific(store_key)); + auto *ptr = reinterpret_cast(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> IdentityStops>::evaluate(con return {}; } - const std::vector& vector = value.get>(); + const auto& vector = value.get>(); if (vector.size() != 2 || !numericValue(vector[0]) || !numericValue(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()) { + if (auto* customLayer = layer->as()) { customLayer->impl->deinitialize(); } } @@ -258,7 +258,7 @@ Layer* Style::addLayer(std::unique_ptr layer, optional befor throw std::runtime_error(std::string{"Layer "} + layer->getID() + " already exists"); } - if (CustomLayer* customLayer = layer->as()) { + if (auto* customLayer = layer->as()) { customLayer->impl->initialize(); } @@ -280,7 +280,7 @@ std::unique_ptr Style::removeLayer(const std::string& id) { auto layer = std::move(*it); - if (CustomLayer* customLayer = layer->as()) { + if (auto* customLayer = layer->as()) { 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(); + const auto& url = urlOrTileset.get(); 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(line[index], line[index + 1]); + auto segmentLength = util::dist(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(a, b); + const auto segmentDist = util::dist(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 getVirtualSegmentAnchor(const Point& segmentBegin, co inline float getMinScaleForSegment(const float glyphDistanceFromAnchor, const Point& segmentAnchor, const Point& segmentEnd) { - const float distanceFromAnchorToEnd = util::dist(segmentAnchor, segmentEnd); + const auto distanceFromAnchorToEnd = util::dist(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 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(*start_itr++); + auto tag_key = static_cast(*start_itr++); if (layerData->keysMap.size() <= tag_key) { throw std::runtime_error("feature referenced out of range key"); @@ -172,7 +172,7 @@ optional VectorTileFeature::getValue(const std::string& key) const { throw std::runtime_error("uneven number of feature tag ids"); } - uint32_t tag_val = static_cast(*start_itr++);; + auto tag_val = static_cast(*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 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(*start_itr++); + auto tag_key = static_cast(*start_itr++); if (start_itr == end_itr) { throw std::runtime_error("uneven number of feature tag ids"); } - uint32_t tag_val = static_cast(*start_itr++); + auto tag_val = static_cast(*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(*g_itr++); + auto cmd_length = static_cast(*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(p, v); - const float l2 = util::distSqr(v, w); + const auto l2 = util::distSqr(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(p, v); if (t > 1) return util::distSqr(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(pthread_getspecific(key)); + auto* ret = reinterpret_cast(pthread_getspecific(key)); if (!ret) { return nullptr; } -- cgit v1.2.1