[tidy] modernize-use-auto
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {};
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user