Use std::optional instead of mbgl::optional (#911)

This commit is contained in:
Bart Louwers
2023-03-17 12:51:59 +01:00
committed by GitHub
parent 36846439c6
commit 15ad65dd3d
482 changed files with 2605 additions and 2652 deletions

View File

@@ -16,6 +16,7 @@
#include <mbgl/util/run_loop.hpp>
#include <sstream>
#include <optional>
using namespace mbgl;
@@ -34,7 +35,7 @@ public:
util::RunLoop loop;
};
void prepare(Map& map, optional<std::string> json = nullopt) {
void prepare(Map& map, std::optional<std::string> json = std::nullopt) {
map.getStyle().loadJSON(json ? *json : util::read_file("benchmark/fixtures/api/style.json"));
map.jumpTo(CameraOptions().withCenter(LatLng { 40.726989, -73.992857 }).withZoom(15.0)); // Manhattan
@@ -42,7 +43,7 @@ void prepare(Map& map, optional<std::string> json = nullopt) {
map.getStyle().addImage(std::make_unique<style::Image>("test-icon", std::move(image), 1.0f));
}
void prepare_map2(Map& map, optional<std::string> json = nullopt) {
void prepare_map2(Map& map, std::optional<std::string> json = std::nullopt) {
map.getStyle().loadJSON(json ? *json : util::read_file("benchmark/fixtures/api/style.json"));
map.jumpTo(CameraOptions().withCenter(LatLng{41.379800, 2.176810}).withZoom(15.0)); // Barcelona

View File

@@ -27,7 +27,7 @@ static void Parse_CameraFunction(benchmark::State& state) {
state.PauseTiming();
auto doc = createFunctionJSON(stopCount);
state.ResumeTiming();
optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, false, false);
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, false, false);
if (!result) {
state.SkipWithError(error.message.c_str());
}
@@ -39,7 +39,7 @@ static void Evaluate_CameraFunction(benchmark::State& state) {
size_t stopCount = state.range(0);
auto doc = createFunctionJSON(stopCount);
conversion::Error error;
optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, false, false);
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, false, false);
if (!function) {
state.SkipWithError(error.message.c_str());
}

View File

@@ -33,7 +33,7 @@ static void Parse_CompositeFunction(benchmark::State& state) {
state.PauseTiming();
auto doc = createFunctionJSON(stopCount);
state.ResumeTiming();
optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
if (!result) {
state.SkipWithError(error.message.c_str());
}
@@ -45,7 +45,7 @@ static void Evaluate_CompositeFunction(benchmark::State& state) {
size_t stopCount = state.range(0);
auto doc = createFunctionJSON(stopCount);
conversion::Error error;
optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
if (!function) {
state.SkipWithError(error.message.c_str());
}

View File

@@ -28,7 +28,7 @@ static void Parse_SourceFunction(benchmark::State& state) {
state.PauseTiming();
auto doc = createFunctionJSON(stopCount);
state.ResumeTiming();
optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
if (!result) {
state.SkipWithError(error.message.c_str());
}
@@ -40,7 +40,7 @@ static void Evaluate_SourceFunction(benchmark::State& state) {
size_t stopCount = state.range(0);
auto doc = createFunctionJSON(stopCount);
conversion::Error error;
optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
if (!function) {
state.SkipWithError(error.message.c_str());
}

View File

@@ -31,8 +31,8 @@ public:
return id;
}
optional<Value> getValue(const std::string& key) const override {
return properties.count(key) ? properties.at(key) : optional<Value>();
std::optional<Value> getValue(const std::string& key) const override {
return properties.count(key) ? properties.at(key) : std::optional<Value>();
}
const GeometryCollection& getGeometries() const override {

View File

@@ -127,7 +127,7 @@ BENCHMARK_F(OfflineDatabase, GetTile)(benchmark::State& state) {
while (state.KeepRunning()) {
auto res = db.get(Resource::tile("mapbox://tile_ambient" + util::toString(dis(gen)), 1, 0, 0, 0, Tileset::Scheme::XYZ));
assert(res != nullopt);
assert(res != std::nullopt);
}
}
@@ -177,7 +177,7 @@ BENCHMARK_F(OfflineDatabase, GetTileFromDisabledDatabase)(benchmark::State& stat
while (state.KeepRunning()) {
auto res = db.get(Resource::tile("mapbox://tile_ambient", 1, 0, 0, 0, Tileset::Scheme::XYZ));
assert(res == nullopt);
assert(res == std::nullopt);
}
}