Use C++20 (#2659)
This commit is contained in:
@@ -13,7 +13,7 @@ PackConstructorInitializers: Never
|
||||
PenaltyBreakAssignment: 80
|
||||
SortIncludes: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
Standard: c++17
|
||||
Standard: c++20
|
||||
---
|
||||
Language: Cpp
|
||||
---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
Checks: >
|
||||
Checks: [
|
||||
android-*,
|
||||
boost-*,
|
||||
bugprone-*,
|
||||
@@ -108,7 +108,9 @@ Checks: >
|
||||
-readability-static-definition-in-anonymous-namespace,
|
||||
-readability-suspicious-call-argument,
|
||||
-readability-uppercase-literal-suffix,
|
||||
-readability-use-anyofallof
|
||||
-readability-use-anyofallof,
|
||||
-modernize-loop-convert # since C++20 this complains about reverse loops with iterators, but good ranges support only landed in clang 15
|
||||
]
|
||||
WarningsAsErrors: '*'
|
||||
HeaderFilterRegex: '.*'
|
||||
CheckOptions:
|
||||
|
||||
@@ -120,7 +120,7 @@ target_link_libraries(
|
||||
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_C_EXTENSIONS OFF)
|
||||
@@ -1382,6 +1382,16 @@ set_source_files_properties(
|
||||
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:-Wno-deprecated-declarations>
|
||||
)
|
||||
|
||||
# gcc 12 compiler bug, remove when fixed
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105651
|
||||
set_source_files_properties(
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/style/expression/compound_expression.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/font_stack.cpp
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS
|
||||
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,12.0.0>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,13.0.0>>:-Wno-restrict>
|
||||
)
|
||||
|
||||
source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${INCLUDE_FILES})
|
||||
source_group(TREE ${PROJECT_SOURCE_DIR}/src FILES ${SRC_FILES})
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ MSVC_FLAGS = [
|
||||
"/wd4435", # (boost) Object layout under /vd2 will change due to virtual base
|
||||
"/wd4702", # Unreachable code
|
||||
"/wd4710", # Function not inlined
|
||||
"/wd5041", # out-of-line definition for constexpr static data member is not needed and is deprecated in C++17
|
||||
"/wd5041", # out-of-line definition for constexpr static data member is not needed and is deprecated since C++17
|
||||
"/wd4946", # reinterpret_cast used between related classes
|
||||
"/wd4459", # declaration of 'x' hides global declaration
|
||||
"/wd4373", # virtual function overrides 'x', previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers
|
||||
@@ -86,12 +86,12 @@ GCC_CLANG_CPP_FLAGS = [
|
||||
"-fexceptions",
|
||||
"-fno-rtti",
|
||||
"-ftemplate-depth=1024",
|
||||
"-std=c++17",
|
||||
"-std=c++20",
|
||||
]
|
||||
|
||||
MSVC_CPP_FLAGS = [
|
||||
"/EHsc",
|
||||
"/std:c++17",
|
||||
"/std:c++20",
|
||||
"/GR-",
|
||||
"/permissive-",
|
||||
"/utf-8",
|
||||
|
||||
@@ -23,6 +23,7 @@ RUN apt-get update \
|
||||
ccache \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
clang-tidy \
|
||||
&& : # end of the RUN cmd - easier to keep a colon at the end of the list, than to keep the backslashes in check
|
||||
|
||||
# This could also be `.../releases/latest/download/bazelisk-linux-amd64` for the latest version, but for predictability better hardcode it
|
||||
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
virtual void eachChild(const std::function<void(const Expression&)>&) const = 0;
|
||||
|
||||
virtual bool operator==(const Expression&) const = 0;
|
||||
bool operator!=(const Expression& rhs) const noexcept { return !operator==(rhs); }
|
||||
bool operator!=(const Expression&) const = default;
|
||||
|
||||
Kind getKind() const noexcept { return kind; };
|
||||
const type::Type& getType() const noexcept { return type; };
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
defaultValue.match([&fn](const style::PropertyExpression<T>& e) { fn(e.getExpression()); }, [](const T&) {});
|
||||
}
|
||||
|
||||
bool operator==(const Expression& e) const final {
|
||||
bool operator==(const Expression& e) const final override {
|
||||
if (e.getKind() == Kind::FormatSectionOverride) {
|
||||
const auto* other = static_cast<const FormatSectionOverride*>(&e);
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const FormatSectionOverride& other) const { return *this == static_cast<const Expression&>(other); }
|
||||
|
||||
std::vector<std::optional<Value>> possibleOutputs() const final { return {std::nullopt}; }
|
||||
|
||||
std::string getOperator() const final { return "format-section-override"; }
|
||||
|
||||
@@ -5,7 +5,7 @@ project(MapLibreAndroid)
|
||||
add_subdirectory(../../../../../
|
||||
../../../../../${ANDROID_ABI})
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
target_compile_options(mbgl-compiler-options INTERFACE -frtti)
|
||||
|
||||
@@ -34,11 +34,11 @@ CGImageRef CGImageCreateWithMLNPremultipliedImage(mbgl::PremultipliedImage&& src
|
||||
constexpr const size_t bytesPerPixel = 4;
|
||||
constexpr const size_t bitsPerPixel = bitsPerComponent * bytesPerPixel;
|
||||
const size_t bytesPerRow = bytesPerPixel * src.size.width;
|
||||
const auto bitmapInfo = static_cast<uint32_t>(kCGBitmapByteOrderDefault) | static_cast<uint32_t>(kCGImageAlphaPremultipliedLast);
|
||||
|
||||
return CGImageCreate(src.size.width, src.size.height, bitsPerComponent, bitsPerPixel,
|
||||
bytesPerRow, *colorSpace,
|
||||
// NOLINTNEXTLINE(bugprone-suspicious-enum-usage)
|
||||
kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast, *provider,
|
||||
bitmapInfo, *provider,
|
||||
NULL, false, kCGRenderingIntentDefault);
|
||||
}
|
||||
|
||||
@@ -56,11 +56,10 @@ mbgl::PremultipliedImage MLNPremultipliedImageFromCGImage(CGImageRef src) {
|
||||
constexpr const size_t bitsPerComponent = 8;
|
||||
constexpr const size_t bytesPerPixel = 4;
|
||||
const size_t bytesPerRow = bytesPerPixel * width;
|
||||
const auto bitmapInfo = static_cast<uint32_t>(kCGBitmapByteOrderDefault) | static_cast<uint32_t>(kCGImageAlphaPremultipliedLast);
|
||||
|
||||
CGContextHandle context(CGBitmapContextCreate(
|
||||
image.data.get(), width, height, bitsPerComponent, bytesPerRow, *colorSpace,
|
||||
// NOLINTNEXTLINE(bugprone-suspicious-enum-usage)
|
||||
kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast));
|
||||
image.data.get(), width, height, bitsPerComponent, bytesPerRow, *colorSpace, bitmapInfo));
|
||||
if (!context) {
|
||||
throw std::runtime_error("CGBitmapContextCreate failed");
|
||||
}
|
||||
|
||||
@@ -234,6 +234,7 @@ PremultipliedImage drawGlyphBitmap(GlyphID glyphID, CTFontRef font, GlyphMetrics
|
||||
constexpr const size_t bitsPerComponent = 8;
|
||||
constexpr const size_t bytesPerPixel = 4;
|
||||
const size_t bytesPerRow = bytesPerPixel * size.width;
|
||||
const auto bitmapInfo = static_cast<uint32_t>(kCGBitmapByteOrderDefault) | static_cast<uint32_t>(kCGImageAlphaPremultipliedLast);
|
||||
|
||||
CGContextHandle context(CGBitmapContextCreate(
|
||||
rgbaBitmap.data.get(),
|
||||
@@ -242,8 +243,7 @@ PremultipliedImage drawGlyphBitmap(GlyphID glyphID, CTFontRef font, GlyphMetrics
|
||||
bitsPerComponent,
|
||||
bytesPerRow,
|
||||
*colorSpace,
|
||||
// NOLINTNEXTLINE(bugprone-suspicious-enum-usage)
|
||||
kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast));
|
||||
bitmapInfo));
|
||||
if (!context) {
|
||||
throw std::runtime_error("CGBitmapContextCreate failed");
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public:
|
||||
ref.invoke(&FileSourceRequest::setResponse, res);
|
||||
};
|
||||
|
||||
auto requestFromNetwork = [=](const Resource& res,
|
||||
std::unique_ptr<AsyncRequest> parent) -> std::unique_ptr<AsyncRequest> {
|
||||
auto requestFromNetwork = [=, this](const Resource& res,
|
||||
std::unique_ptr<AsyncRequest> parent) -> std::unique_ptr<AsyncRequest> {
|
||||
if (!onlineFileSource || !onlineFileSource->canRequest(resource)) {
|
||||
return parent;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
std::shared_ptr<AsyncRequest> parentKeepAlive = std::move(parent);
|
||||
|
||||
MBGL_TIMING_START(watch);
|
||||
return onlineFileSource->request(res, [=, ptr = parentKeepAlive](const Response& response) {
|
||||
return onlineFileSource->request(res, [=, ptr = parentKeepAlive, this](const Response& response) {
|
||||
if (databaseFileSource) {
|
||||
databaseFileSource->forward(res, response, nullptr);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
tasks[req] = databaseFileSource->request(resource, callback);
|
||||
} else {
|
||||
// Cache request with fallback to network with cache control
|
||||
tasks[req] = databaseFileSource->request(resource, [=](const Response& response) {
|
||||
tasks[req] = databaseFileSource->request(resource, [=, this](const Response& response) {
|
||||
Resource res = resource;
|
||||
|
||||
// Resource is in the cache
|
||||
|
||||
@@ -273,7 +273,7 @@ void OfflineDownload::activateDownload() {
|
||||
sourceResource.setPriority(Resource::Priority::Low);
|
||||
sourceResource.setUsage(Resource::Usage::Offline);
|
||||
|
||||
ensureResource(std::move(sourceResource), [=](const Response& sourceResponse) {
|
||||
ensureResource(std::move(sourceResource), [=, this](const Response& sourceResponse) {
|
||||
style::conversion::Error error;
|
||||
std::optional<Tileset> tileset = style::conversion::convertJSON<Tileset>(*sourceResponse.data,
|
||||
error);
|
||||
@@ -467,7 +467,7 @@ void OfflineDownload::ensureResource(Resource&& resource, std::function<void(Res
|
||||
assert(resource.usage == Resource::Usage::Offline);
|
||||
|
||||
auto workRequestsIt = requests.insert(requests.begin(), nullptr);
|
||||
*workRequestsIt = util::RunLoop::Get()->invokeCancellable([=]() {
|
||||
*workRequestsIt = util::RunLoop::Get()->invokeCancellable([=, this]() {
|
||||
requests.erase(workRequestsIt);
|
||||
const auto resourceKind = resource.kind;
|
||||
auto getResourceSizeInDatabase = [&]() -> std::optional<int64_t> {
|
||||
@@ -507,7 +507,7 @@ void OfflineDownload::ensureResource(Resource&& resource, std::function<void(Res
|
||||
}
|
||||
|
||||
auto fileRequestsIt = requests.insert(requests.begin(), nullptr);
|
||||
*fileRequestsIt = onlineFileSource.request(resource, [=](const Response& onlineResponse) {
|
||||
*fileRequestsIt = onlineFileSource.request(resource, [=, this](const Response& onlineResponse) {
|
||||
if (onlineResponse.error) {
|
||||
observer->responseError(*onlineResponse.error);
|
||||
if (onlineResponse.error->reason == Response::Error::Reason::NotFound) {
|
||||
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
void queueRequest(OnlineFileRequest* req) { pendingRequests.insert(req); }
|
||||
|
||||
void activateRequest(OnlineFileRequest* req) {
|
||||
auto callback = [=](const Response& response) {
|
||||
auto callback = [=, this](const Response& response) {
|
||||
activeRequests.erase(req);
|
||||
req->request.reset();
|
||||
req->completed(response);
|
||||
|
||||
@@ -153,9 +153,6 @@ std::size_t VertexAttributeGL::getStride() const {
|
||||
return getStride(getGLType());
|
||||
}
|
||||
|
||||
namespace {
|
||||
const std::vector<std::uint8_t> noData;
|
||||
}
|
||||
const std::vector<std::uint8_t>& VertexAttributeGL::getRaw(gfx::VertexAttribute& attr, platform::GLenum type) {
|
||||
const auto count = attr.getCount();
|
||||
const auto stride_ = getStride(type);
|
||||
|
||||
@@ -142,7 +142,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
|
||||
startTransition(
|
||||
camera,
|
||||
animation,
|
||||
[=](double t) {
|
||||
[=, this](double t) {
|
||||
Point<double> framePoint = util::interpolate(startPoint, endPoint, t);
|
||||
LatLng frameLatLng = Projection::unproject(framePoint, state.zoomScale(startZoom));
|
||||
double frameZoom = util::interpolate(startZoom, zoom, t);
|
||||
@@ -299,7 +299,7 @@ void Transform::flyTo(const CameraOptions& camera, const AnimationOptions& anima
|
||||
startTransition(
|
||||
camera,
|
||||
animation,
|
||||
[=](double k) {
|
||||
[=, this](double k) {
|
||||
/// s: The distance traveled along the flight path, measured in
|
||||
/// ρ-screenfuls.
|
||||
double s = k * S;
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
namespace mbgl {
|
||||
|
||||
struct ZoomHistory {
|
||||
float lastZoom;
|
||||
float lastFloorZoom;
|
||||
float lastIntegerZoom;
|
||||
float lastZoom = 0;
|
||||
float lastFloorZoom = 0;
|
||||
float lastIntegerZoom = 0;
|
||||
TimePoint lastIntegerZoomTime;
|
||||
bool first = true;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
uint64_t imageCorrelationID) = 0;
|
||||
|
||||
void addPendingRequest(const std::string& imageId) { pendingRequests.insert(imageId); }
|
||||
bool hasPendingRequest(const std::string& imageId) const { return pendingRequests.count(imageId); }
|
||||
bool hasPendingRequest(const std::string& imageId) const { return pendingRequests.contains(imageId); }
|
||||
bool hasPendingRequests() const { return !pendingRequests.empty(); }
|
||||
void removePendingRequest(const std::string& imageId) { pendingRequests.erase(imageId); }
|
||||
|
||||
|
||||
@@ -137,10 +137,6 @@ struct SegmentGroup {
|
||||
bool operator<(const SegmentGroup& other) const { return renderable < other.renderable; }
|
||||
};
|
||||
|
||||
namespace {
|
||||
const SegmentVector<SymbolTextAttributes> emptySegmentVector;
|
||||
}
|
||||
|
||||
#if MLN_LEGACY_RENDERER
|
||||
|
||||
template <typename DrawFn>
|
||||
@@ -726,6 +722,8 @@ void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
|
||||
|
||||
namespace {
|
||||
|
||||
const SegmentVector<SymbolTextAttributes> emptySegmentVector;
|
||||
|
||||
template <typename TText, typename TIcon>
|
||||
const auto& getProperty(const SymbolBucket::PaintProperties& paintProps, bool isText) {
|
||||
return isText ? paintProps.textBinders.get<TText>() : paintProps.iconBinders.get<TIcon>();
|
||||
|
||||
@@ -306,7 +306,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
|
||||
std::unordered_set<std::string> constantsMaskChanged;
|
||||
for (RenderLayer& layer : orderedLayers) {
|
||||
const std::string& id = layer.getID();
|
||||
const bool layerAddedOrChanged = layerDiff.added.count(id) || layerDiff.changed.count(id);
|
||||
const bool layerAddedOrChanged = layerDiff.added.contains(id) || layerDiff.changed.contains(id);
|
||||
evaluationParameters.layerChanged = layerAddedOrChanged;
|
||||
evaluationParameters.hasCrossfade = layer.hasCrossfade();
|
||||
|
||||
@@ -383,7 +383,8 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
|
||||
if (layerInfo->source != LayerTypeInfo::Source::NotRequired) {
|
||||
if (layer.baseImpl->source == sourceImpl->id) {
|
||||
const std::string& layerId = layer.getID();
|
||||
sourceNeedsRelayout = (sourceNeedsRelayout || hasImageDiff || constantsMaskChanged.count(layerId) ||
|
||||
sourceNeedsRelayout = (sourceNeedsRelayout || hasImageDiff ||
|
||||
constantsMaskChanged.contains(layerId) ||
|
||||
hasLayoutDifference(layerDiff, layerId));
|
||||
if (layerIsVisible) {
|
||||
filteredLayersForSource.push_back(layer.evaluatedProperties);
|
||||
|
||||
@@ -110,18 +110,17 @@ void SourceFeatureState::removeState(const std::optional<std::string>& sourceLay
|
||||
const std::optional<std::string>& stateKey) {
|
||||
std::string sourceLayer = sourceLayerID.value_or(std::string());
|
||||
|
||||
bool sourceLayerDeleted = (deletedStates.count(sourceLayer) > 0) && deletedStates[sourceLayer].empty();
|
||||
bool sourceLayerDeleted = deletedStates.contains(sourceLayer) && deletedStates[sourceLayer].empty();
|
||||
if (sourceLayerDeleted) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (stateKey && featureID) {
|
||||
if ((deletedStates.count(sourceLayer) == 0) && (deletedStates[sourceLayer].count(*featureID)) == 0) {
|
||||
if (!deletedStates.contains(sourceLayer) && !deletedStates[sourceLayer].contains(*featureID)) {
|
||||
deletedStates[sourceLayer][*featureID][*stateKey] = {};
|
||||
}
|
||||
} else if (featureID) {
|
||||
bool updateInQueue = (stateChanges.count(sourceLayer) != 0U) &&
|
||||
(stateChanges[sourceLayer].count(*featureID) != 0U);
|
||||
bool updateInQueue = stateChanges.contains(sourceLayer) && stateChanges[sourceLayer].contains(*featureID);
|
||||
if (updateInQueue) {
|
||||
for (const auto& changeEntry : stateChanges[sourceLayer][*featureID]) {
|
||||
deletedStates[sourceLayer][*featureID][changeEntry.first] = {};
|
||||
|
||||
@@ -62,7 +62,7 @@ LayerDifference diffLayers(const Immutable<std::vector<ImmutableLayer>>& a,
|
||||
}
|
||||
|
||||
bool hasLayoutDifference(const LayerDifference& layerDiff, const std::string& layerID) {
|
||||
if (layerDiff.added.count(layerID)) return true;
|
||||
if (layerDiff.added.contains(layerID)) return true;
|
||||
const auto it = layerDiff.changed.find(layerID);
|
||||
if (it == layerDiff.changed.end()) return false;
|
||||
return it->second.before->hasLayoutDifference(*it->second.after);
|
||||
|
||||
@@ -1098,6 +1098,7 @@ std::string expectedTypesError(const Definitions& definitions, const std::vector
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
std::string signatures = overloads.empty() ? boost::algorithm::join(availableOverloads, " | ")
|
||||
: boost::algorithm::join(overloads, " | ");
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ std::shared_ptr<GeoJSONData> GeoJSONData::create(const GeoJSON& geoJSON,
|
||||
};
|
||||
clusterOptions.reduce = [feature, options](PropertyMap& toReturn, const PropertyMap& toFill) {
|
||||
for (const auto& p : options->clusterProperties) {
|
||||
if (toFill.count(p.first) == 0) {
|
||||
if (!toFill.contains(p.first)) {
|
||||
continue;
|
||||
}
|
||||
feature->properties = toFill;
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
static Observer nullObserver;
|
||||
|
||||
Style::Impl::Impl(std::shared_ptr<FileSource> fileSource_, float pixelRatio, const TaggedScheduler& threadPool_)
|
||||
: fileSource(std::move(fileSource_)),
|
||||
spriteLoader(std::make_unique<SpriteLoader>(pixelRatio, threadPool_)),
|
||||
|
||||
@@ -203,7 +203,7 @@ bool CrossTileSymbolLayerIndex::removeStaleBuckets(const std::unordered_set<uint
|
||||
bool tilesChanged = false;
|
||||
for (auto& zoomIndexes : indexes) {
|
||||
for (auto it = zoomIndexes.second.begin(); it != zoomIndexes.second.end();) {
|
||||
if (!currentIDs.count(it->second.bucketInstanceId)) {
|
||||
if (!currentIDs.contains(it->second.bucketInstanceId)) {
|
||||
removeBucketCrossTileIDs(zoomIndexes.first, it->second);
|
||||
it = zoomIndexes.second.erase(it);
|
||||
tilesChanged = true;
|
||||
|
||||
@@ -249,7 +249,7 @@ void Placement::placeSymbolBucket(const BucketPlacementData& params, std::set<ui
|
||||
collisionGroups.get(params.sourceId),
|
||||
getAvoidEdges(symbolBucket, renderTile.matrix)};
|
||||
for (const SymbolInstance& symbol : getSortedSymbols(params, ctx.pixelRatio)) {
|
||||
if (seenCrossTileIDs.count(symbol.crossTileID) != 0u) continue;
|
||||
if (seenCrossTileIDs.contains(symbol.crossTileID)) continue;
|
||||
placeSymbol(symbol, ctx);
|
||||
|
||||
// Prevent a flickering issue while zooming out.
|
||||
@@ -983,7 +983,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket,
|
||||
true);
|
||||
|
||||
for (SymbolInstance& symbolInstance : bucket.symbolInstances) {
|
||||
bool isDuplicate = seenCrossTileIDs.count(symbolInstance.crossTileID) > 0;
|
||||
bool isDuplicate = seenCrossTileIDs.contains(symbolInstance.crossTileID);
|
||||
|
||||
auto it = opacities.find(symbolInstance.crossTileID);
|
||||
auto opacityState = defaultOpacityState;
|
||||
@@ -1414,7 +1414,7 @@ void TilePlacement::placeLayers(const RenderLayerReferences& layers) {
|
||||
const SymbolInstance& symbol = intersection.symbol;
|
||||
const PlacementContext& ctx = intersection.ctx;
|
||||
currentIntersectionPriority = intersection.priority;
|
||||
if (seenCrossTileIDs.count(symbol.crossTileID) != 0u) continue;
|
||||
if (seenCrossTileIDs.contains(symbol.crossTileID)) continue;
|
||||
JointPlacement placement = placeSymbol(symbol, ctx);
|
||||
if (shouldRetryPlacement(placement, ctx)) continue;
|
||||
seenCrossTileIDs.insert(symbol.crossTileID);
|
||||
|
||||
@@ -265,7 +265,7 @@ void GridIndex<T>::query(const BBox& queryBBox, std::function<bool(const T&, con
|
||||
cellIndex = xCellCount * y + x;
|
||||
// Look up other boxes
|
||||
for (auto uid : boxCells[cellIndex]) {
|
||||
if (seenBoxes.count(uid) == 0) {
|
||||
if (!seenBoxes.contains(uid)) {
|
||||
seenBoxes.insert(uid);
|
||||
|
||||
auto& pair = boxElements.at(uid);
|
||||
@@ -280,7 +280,7 @@ void GridIndex<T>::query(const BBox& queryBBox, std::function<bool(const T&, con
|
||||
|
||||
// Look up circles
|
||||
for (auto uid : circleCells[cellIndex]) {
|
||||
if (seenCircles.count(uid) == 0) {
|
||||
if (!seenCircles.contains(uid)) {
|
||||
seenCircles.insert(uid);
|
||||
|
||||
auto& pair = circleElements.at(uid);
|
||||
@@ -330,7 +330,7 @@ void GridIndex<T>::query(const BCircle& queryBCircle, std::function<bool(const T
|
||||
cellIndex = xCellCount * y + x;
|
||||
// Look up boxes
|
||||
for (auto uid : boxCells[cellIndex]) {
|
||||
if (seenBoxes.count(uid) == 0) {
|
||||
if (!seenBoxes.contains(uid)) {
|
||||
seenBoxes.insert(uid);
|
||||
|
||||
auto& pair = boxElements.at(uid);
|
||||
@@ -345,7 +345,7 @@ void GridIndex<T>::query(const BCircle& queryBCircle, std::function<bool(const T
|
||||
|
||||
// Look up other circles
|
||||
for (auto uid : circleCells[cellIndex]) {
|
||||
if (seenCircles.count(uid) == 0) {
|
||||
if (!seenCircles.contains(uid)) {
|
||||
seenCircles.insert(uid);
|
||||
|
||||
auto& pair = circleElements.at(uid);
|
||||
|
||||
@@ -371,12 +371,12 @@ TEST(Annotations, QueryRenderedFeatures) {
|
||||
ASSERT_NEAR(points[1].y, point1.y, 1e-8);
|
||||
|
||||
auto features = test.frontend.getRenderer()->queryRenderedFeatures(point0);
|
||||
EXPECT_EQ(features.size(), 1u);
|
||||
ASSERT_EQ(features.size(), 1u);
|
||||
EXPECT_EQ(features[0].id.is<NullValue>(), false);
|
||||
EXPECT_EQ(features[0].id, uint64_t(0));
|
||||
|
||||
auto features2 = test.frontend.getRenderer()->queryRenderedFeatures(point1);
|
||||
EXPECT_EQ(features2.size(), 1u);
|
||||
ASSERT_EQ(features2.size(), 1u);
|
||||
EXPECT_EQ(features[0].id.is<NullValue>(), false);
|
||||
EXPECT_EQ(features2[0].id, uint64_t(1));
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ TEST(Query, QueryFeatureExtensionsSuperclusterChildren) {
|
||||
QueryTest test;
|
||||
auto topClusterFeature = getTopClusterFeature(test);
|
||||
|
||||
EXPECT_EQ(topClusterFeature.size(), 1u);
|
||||
ASSERT_EQ(topClusterFeature.size(), 1u);
|
||||
const auto featureProps = topClusterFeature[0].properties;
|
||||
auto clusterId = featureProps.find("cluster_id"s);
|
||||
auto cluster = featureProps.find("cluster"s);
|
||||
@@ -213,7 +213,7 @@ TEST(Query, QueryFeatureExtensionsSuperclusterChildren) {
|
||||
|
||||
EXPECT_TRUE(queryChildren.is<FeatureCollection>());
|
||||
auto children = queryChildren.get<FeatureCollection>();
|
||||
EXPECT_EQ(children.size(), 4u);
|
||||
ASSERT_EQ(children.size(), 4u);
|
||||
|
||||
// Compare results produced by supercluster with default clustering options.
|
||||
EXPECT_EQ(children[0].properties["cluster_id"].get<uint64_t>(), 2u);
|
||||
@@ -229,7 +229,7 @@ TEST(Query, QueryFeatureExtensionsSuperclusterChildren) {
|
||||
TEST(Query, QueryFeatureExtensionsSuperclusterExpansionZoom) {
|
||||
QueryTest test;
|
||||
auto topClusterFeature = getTopClusterFeature(test);
|
||||
EXPECT_EQ(topClusterFeature.size(), 1u);
|
||||
ASSERT_EQ(topClusterFeature.size(), 1u);
|
||||
|
||||
auto queryChildren = test.frontend.getRenderer()->queryFeatureExtensions(
|
||||
"cluster_source"s, topClusterFeature[0], "supercluster"s, "children"s);
|
||||
@@ -251,7 +251,7 @@ TEST(Query, QueryFeatureExtensionsSuperclusterExpansionZoom) {
|
||||
TEST(Query, QueryFeatureExtensionsSuperclusterLeaves) {
|
||||
QueryTest test;
|
||||
auto topClusterFeature = getTopClusterFeature(test);
|
||||
EXPECT_EQ(topClusterFeature.size(), 1u);
|
||||
ASSERT_EQ(topClusterFeature.size(), 1u);
|
||||
|
||||
// Get leaves for cluster 1, with default limit 10, offset 0.
|
||||
auto queryClusterLeaves = test.frontend.getRenderer()->queryFeatureExtensions(
|
||||
@@ -265,7 +265,7 @@ TEST(Query, QueryFeatureExtensionsSuperclusterLeaves) {
|
||||
auto queryClusterLeavesLimit3 = test.frontend.getRenderer()->queryFeatureExtensions(
|
||||
"cluster_source"s, topClusterFeature[0], "supercluster"s, "leaves"s, limitOpts);
|
||||
auto limitLeaves3 = queryClusterLeavesLimit3.get<FeatureCollection>();
|
||||
EXPECT_EQ(limitLeaves3.size(), 3u);
|
||||
ASSERT_EQ(limitLeaves3.size(), 3u);
|
||||
|
||||
EXPECT_EQ(limitLeaves3[0].properties["name"].get<std::string>(), "Niagara Falls"s);
|
||||
EXPECT_EQ(limitLeaves3[1].properties["name"].get<std::string>(), "Cape May"s);
|
||||
|
||||
@@ -140,9 +140,9 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(ExpiresParsing)) {
|
||||
EXPECT_EQ(nullptr, res.error);
|
||||
ASSERT_TRUE(res.data.get());
|
||||
EXPECT_EQ("Hello World!", *res.data);
|
||||
EXPECT_EQ(Timestamp{Seconds(1420797926)}, res.expires);
|
||||
EXPECT_TRUE(Timestamp{Seconds(1420797926)} == res.expires);
|
||||
EXPECT_FALSE(res.mustRevalidate);
|
||||
EXPECT_EQ(Timestamp{Seconds(1420794326)}, res.modified);
|
||||
EXPECT_TRUE(Timestamp{Seconds(1420794326)} == res.modified);
|
||||
EXPECT_EQ("foo", *res.etag);
|
||||
loop.stop();
|
||||
});
|
||||
|
||||
@@ -42,9 +42,9 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CacheResponse)) {
|
||||
EXPECT_EQ(response.error, res2.error);
|
||||
ASSERT_TRUE(res2.data.get());
|
||||
EXPECT_EQ(*response.data, *res2.data);
|
||||
EXPECT_EQ(response.expires, res2.expires);
|
||||
EXPECT_TRUE(response.expires == res2.expires);
|
||||
EXPECT_EQ(response.mustRevalidate, res2.mustRevalidate);
|
||||
EXPECT_EQ(response.modified, res2.modified);
|
||||
EXPECT_TRUE(response.modified == res2.modified);
|
||||
EXPECT_EQ(response.etag, res2.etag);
|
||||
|
||||
loop.stop();
|
||||
@@ -166,7 +166,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CacheRevalidateModified)) {
|
||||
EXPECT_EQ("Response", *res.data);
|
||||
EXPECT_FALSE(bool(res.expires));
|
||||
EXPECT_TRUE(res.mustRevalidate);
|
||||
EXPECT_EQ(Timestamp{Seconds(1420070400)}, *res.modified);
|
||||
EXPECT_TRUE(Timestamp{Seconds(1420070400)} == *res.modified);
|
||||
EXPECT_FALSE(res.etag);
|
||||
|
||||
// The first response is stored in the cache, but it has
|
||||
@@ -188,7 +188,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CacheRevalidateModified)) {
|
||||
EXPECT_EQ("Response", *res2.data);
|
||||
EXPECT_TRUE(bool(res2.expires));
|
||||
EXPECT_TRUE(res2.mustRevalidate);
|
||||
EXPECT_EQ(Timestamp{Seconds(1420070400)}, *res2.modified);
|
||||
EXPECT_TRUE(Timestamp{Seconds(1420070400)} == *res2.modified);
|
||||
EXPECT_FALSE(res2.etag);
|
||||
} else {
|
||||
// The test server sends a Cache-Control header with a max-age
|
||||
@@ -203,7 +203,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CacheRevalidateModified)) {
|
||||
EXPECT_FALSE(res2.data.get());
|
||||
EXPECT_TRUE(bool(res2.expires));
|
||||
EXPECT_TRUE(res2.mustRevalidate);
|
||||
EXPECT_EQ(Timestamp{Seconds(1420070400)}, *res2.modified);
|
||||
EXPECT_TRUE(Timestamp{Seconds(1420070400)} == *res2.modified);
|
||||
EXPECT_FALSE(res2.etag);
|
||||
loop.stop();
|
||||
}
|
||||
@@ -311,7 +311,7 @@ TEST(MainResourceLoader, OptionalNonExpired) {
|
||||
ASSERT_TRUE(res.data.get());
|
||||
EXPECT_EQ("Cached value", *res.data);
|
||||
ASSERT_TRUE(bool(res.expires));
|
||||
EXPECT_EQ(*response.expires, *res.expires);
|
||||
EXPECT_TRUE(*response.expires == *res.expires);
|
||||
EXPECT_FALSE(res.mustRevalidate);
|
||||
EXPECT_FALSE(bool(res.modified));
|
||||
EXPECT_FALSE(bool(res.etag));
|
||||
@@ -344,7 +344,7 @@ TEST(MainResourceLoader, OptionalExpired) {
|
||||
ASSERT_TRUE(res.data.get());
|
||||
EXPECT_EQ("Cached value", *res.data);
|
||||
ASSERT_TRUE(bool(res.expires));
|
||||
EXPECT_EQ(*response.expires, *res.expires);
|
||||
EXPECT_TRUE(*response.expires == *res.expires);
|
||||
EXPECT_FALSE(res.mustRevalidate);
|
||||
EXPECT_FALSE(bool(res.modified));
|
||||
EXPECT_FALSE(bool(res.etag));
|
||||
@@ -406,7 +406,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(NoCacheRefreshEtagNotModified)) {
|
||||
EXPECT_TRUE(res.notModified);
|
||||
EXPECT_FALSE(res.data.get());
|
||||
ASSERT_TRUE(bool(res.expires));
|
||||
EXPECT_LT(util::now(), *res.expires);
|
||||
EXPECT_TRUE(util::now() < *res.expires);
|
||||
EXPECT_TRUE(res.mustRevalidate);
|
||||
EXPECT_FALSE(bool(res.modified));
|
||||
ASSERT_TRUE(bool(res.etag));
|
||||
@@ -517,10 +517,10 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(NoCacheRefreshModifiedNotModified)
|
||||
EXPECT_TRUE(res.notModified);
|
||||
EXPECT_FALSE(res.data.get());
|
||||
ASSERT_TRUE(bool(res.expires));
|
||||
EXPECT_LT(util::now(), *res.expires);
|
||||
EXPECT_TRUE(util::now() < *res.expires);
|
||||
EXPECT_TRUE(res.mustRevalidate);
|
||||
ASSERT_TRUE(bool(res.modified));
|
||||
EXPECT_EQ(Timestamp{Seconds(1420070400)}, *res.modified);
|
||||
EXPECT_TRUE(Timestamp{Seconds(1420070400)} == *res.modified);
|
||||
EXPECT_FALSE(bool(res.etag));
|
||||
loop.stop();
|
||||
});
|
||||
@@ -557,7 +557,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(NoCacheRefreshModifiedModified)) {
|
||||
EXPECT_EQ("Response", *res.data);
|
||||
EXPECT_FALSE(bool(res.expires));
|
||||
EXPECT_TRUE(res.mustRevalidate);
|
||||
EXPECT_EQ(Timestamp{Seconds(1420070400)}, *res.modified);
|
||||
EXPECT_TRUE(Timestamp{Seconds(1420070400)} == *res.modified);
|
||||
EXPECT_FALSE(res.etag);
|
||||
loop.stop();
|
||||
});
|
||||
@@ -662,10 +662,10 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(RespondToStaleMustRevalidate)) {
|
||||
ASSERT_TRUE(res.data.get());
|
||||
EXPECT_EQ("Cached value", *res.data);
|
||||
ASSERT_TRUE(res.expires);
|
||||
EXPECT_EQ(Timestamp{Seconds(1417392000)}, *res.expires);
|
||||
EXPECT_TRUE(Timestamp{Seconds(1417392000)} == *res.expires);
|
||||
EXPECT_TRUE(res.mustRevalidate);
|
||||
ASSERT_TRUE(res.modified);
|
||||
EXPECT_EQ(Timestamp{Seconds(1417392000)}, *res.modified);
|
||||
EXPECT_TRUE(Timestamp{Seconds(1417392000)} == *res.modified);
|
||||
ASSERT_TRUE(res.etag);
|
||||
EXPECT_EQ("snowfall", *res.etag);
|
||||
|
||||
@@ -702,10 +702,10 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(RespondToStaleMustRevalidate)) {
|
||||
// a 304 Not Modified response.
|
||||
EXPECT_EQ("Prior value", *res.data);
|
||||
ASSERT_TRUE(res.expires);
|
||||
EXPECT_LE(util::now(), *res.expires);
|
||||
EXPECT_TRUE(util::now() <= *res.expires);
|
||||
EXPECT_TRUE(res.mustRevalidate);
|
||||
ASSERT_TRUE(res.modified);
|
||||
EXPECT_EQ(Timestamp{Seconds(1417392000)}, *res.modified);
|
||||
EXPECT_TRUE(Timestamp{Seconds(1417392000)} == *res.modified);
|
||||
ASSERT_TRUE(res.etag);
|
||||
EXPECT_EQ("snowfall", *res.etag);
|
||||
loop.stop();
|
||||
|
||||
@@ -1790,7 +1790,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(MergeDatabaseWithSingleRegion_Update))
|
||||
auto updatedTile = db.getRegionResource(Resource::tile(tileURL, 1, 0, 0, 1, Tileset::Scheme::XYZ));
|
||||
|
||||
auto updatedStamp = updatedTile->first.modified;
|
||||
EXPECT_EQ(*originalStamp, *updatedStamp);
|
||||
EXPECT_TRUE(*originalStamp == *updatedStamp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1815,7 +1815,7 @@ TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_NoUpdate) {
|
||||
auto updatedTile = db.getRegionResource(Resource::tile(tileURL, 1, 0, 0, 1, Tileset::Scheme::XYZ));
|
||||
|
||||
// Verify the modified timestamp matches the tile in the main db.
|
||||
EXPECT_EQ(originalStamp, updatedTile->first.modified);
|
||||
EXPECT_TRUE(originalStamp == updatedTile->first.modified);
|
||||
}
|
||||
|
||||
TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_AmbientTiles) {
|
||||
|
||||
@@ -155,7 +155,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RetryDelayOnExpiredTile)) {
|
||||
std::unique_ptr<AsyncRequest> req = fs->request(resource, [&](Response res) {
|
||||
counter++;
|
||||
EXPECT_EQ(nullptr, res.error);
|
||||
EXPECT_GT(util::now(), *res.expires);
|
||||
EXPECT_TRUE(util::now() > *res.expires);
|
||||
EXPECT_FALSE(res.mustRevalidate);
|
||||
loop.stop();
|
||||
});
|
||||
@@ -177,14 +177,14 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RetryOnClockSkew)) {
|
||||
switch (counter++) {
|
||||
case 0: {
|
||||
EXPECT_EQ(nullptr, res.error);
|
||||
EXPECT_GT(util::now(), *res.expires);
|
||||
EXPECT_TRUE(util::now() > *res.expires);
|
||||
} break;
|
||||
case 1: {
|
||||
EXPECT_EQ(nullptr, res.error);
|
||||
|
||||
auto now = util::now();
|
||||
EXPECT_LT(now + Seconds(40), *res.expires) << "Expiration not interpolated to 60s";
|
||||
EXPECT_GT(now + Seconds(80), *res.expires) << "Expiration not interpolated to 60s";
|
||||
EXPECT_TRUE(now + Seconds(40) < *res.expires) << "Expiration not interpolated to 60s";
|
||||
EXPECT_TRUE(now + Seconds(80) > *res.expires) << "Expiration not interpolated to 60s";
|
||||
|
||||
loop.stop();
|
||||
} break;
|
||||
@@ -385,7 +385,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RateLimitStandard)) {
|
||||
ASSERT_NE(nullptr, res.error);
|
||||
EXPECT_EQ(Response::Error::Reason::RateLimit, res.error->reason);
|
||||
ASSERT_EQ(true, bool(res.error->retryAfter));
|
||||
ASSERT_LT(util::now(), res.error->retryAfter);
|
||||
ASSERT_TRUE(util::now() < res.error->retryAfter);
|
||||
loop.stop();
|
||||
});
|
||||
|
||||
@@ -400,7 +400,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RateLimitMBX)) {
|
||||
ASSERT_NE(nullptr, res.error);
|
||||
EXPECT_EQ(Response::Error::Reason::RateLimit, res.error->reason);
|
||||
ASSERT_EQ(true, bool(res.error->retryAfter));
|
||||
ASSERT_LT(util::now(), res.error->retryAfter);
|
||||
ASSERT_TRUE(util::now() < res.error->retryAfter);
|
||||
loop.stop();
|
||||
});
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ void benchmark(const std::string_view label,
|
||||
for (std::size_t j = 0; j < lookups; ++j) {
|
||||
for (const auto& k : testKeys) {
|
||||
if (map.count(k)) {
|
||||
do_not_optimize_away++;
|
||||
do_not_optimize_away = do_not_optimize_away + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user