diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-07-30 15:04:41 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-07-30 17:17:38 -0700 |
commit | 9a1bb1ad14e18433d4cc8e805af57a6014275561 (patch) | |
tree | 60533ceadc7bebe48d655041b9c4dbcf4133c32a /src/mbgl/style/conversion/tileset.cpp | |
parent | bf7785618ac5f3bbcba068e61ef6359d70aff92b (diff) | |
download | qtlocation-mapboxgl-9a1bb1ad14e18433d4cc8e805af57a6014275561.tar.gz |
[core] Tweak conversions to reduce binary size
* return {} → return nullopt
* error = { "..." } → error.message = "..."
Diffstat (limited to 'src/mbgl/style/conversion/tileset.cpp')
-rw-r--r-- | src/mbgl/style/conversion/tileset.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/mbgl/style/conversion/tileset.cpp b/src/mbgl/style/conversion/tileset.cpp index fe3254b149..fb2ae6c6a0 100644 --- a/src/mbgl/style/conversion/tileset.cpp +++ b/src/mbgl/style/conversion/tileset.cpp @@ -11,20 +11,20 @@ optional<Tileset> Converter<Tileset>::operator()(const Convertible& value, Error auto tiles = objectMember(value, "tiles"); if (!tiles) { - error = { "source must have tiles" }; - return {}; + error.message = "source must have tiles"; + return nullopt; } if (!isArray(*tiles)) { - error = { "source tiles must be an array" }; - return {}; + error.message = "source tiles must be an array"; + return nullopt; } for (std::size_t i = 0; i < arrayLength(*tiles); i++) { optional<std::string> urlTemplate = toString(arrayMember(*tiles, i)); if (!urlTemplate) { - error = { "source tiles member must be a string" }; - return {}; + error.message = "source tiles member must be a string"; + return nullopt; } result.tiles.push_back(std::move(*urlTemplate)); } @@ -43,7 +43,7 @@ optional<Tileset> Converter<Tileset>::operator()(const Convertible& value, Error if (encoding && *encoding == "terrarium") { result.encoding = Tileset::DEMEncoding::Terrarium; } else if (encoding && *encoding != "mapbox") { - error = { "invalid raster-dem encoding type - valid types are 'mapbox' and 'terrarium' " }; + error.message = "invalid raster-dem encoding type - valid types are 'mapbox' and 'terrarium' "; } } @@ -51,8 +51,8 @@ optional<Tileset> Converter<Tileset>::operator()(const Convertible& value, Error if (minzoomValue) { optional<float> minzoom = toNumber(*minzoomValue); if (!minzoom || *minzoom < 0 || *minzoom > std::numeric_limits<uint8_t>::max()) { - error = { "invalid minzoom" }; - return {}; + error.message = "invalid minzoom"; + return nullopt; } result.zoomRange.min = *minzoom; } @@ -61,8 +61,8 @@ optional<Tileset> Converter<Tileset>::operator()(const Convertible& value, Error if (maxzoomValue) { optional<float> maxzoom = toNumber(*maxzoomValue); if (!maxzoom || *maxzoom < 0 || *maxzoom > std::numeric_limits<uint8_t>::max()) { - error = { "invalid maxzoom" }; - return {}; + error.message = "invalid maxzoom"; + return nullopt; } result.zoomRange.max = *maxzoom; } @@ -71,8 +71,8 @@ optional<Tileset> Converter<Tileset>::operator()(const Convertible& value, Error if (attributionValue) { optional<std::string> attribution = toString(*attributionValue); if (!attribution) { - error = { "source attribution must be a string" }; - return {}; + error.message = "source attribution must be a string"; + return nullopt; } result.attribution = std::move(*attribution); } @@ -80,8 +80,8 @@ optional<Tileset> Converter<Tileset>::operator()(const Convertible& value, Error auto boundsValue = objectMember(value, "bounds"); if (boundsValue) { if (!isArray(*boundsValue) || arrayLength(*boundsValue) != 4) { - error = { "bounds must be an array with left, bottom, top, and right values" }; - return {}; + error.message = "bounds must be an array with left, bottom, top, and right values"; + return nullopt; } optional<double> left = toDouble(arrayMember(*boundsValue, 0)); optional<double> bottom = toDouble(arrayMember(*boundsValue, 1)); @@ -89,20 +89,20 @@ optional<Tileset> Converter<Tileset>::operator()(const Convertible& value, Error optional<double> top = toDouble(arrayMember(*boundsValue, 3)); if (!left || !right || !bottom || !top) { - error = { "bounds array must contain numeric longitude and latitude values" }; - return {}; + error.message = "bounds array must contain numeric longitude and latitude values"; + return nullopt; } bottom = util::clamp(*bottom, -90.0, 90.0); top = util::clamp(*top, -90.0, 90.0); if (top <= bottom){ - error = { "bounds bottom latitude must be smaller than top latitude" }; - return {}; + error.message = "bounds bottom latitude must be smaller than top latitude"; + return nullopt; } if(*left >= *right) { - error = { "bounds left longitude should be less than right longitude" }; - return {}; + error.message = "bounds left longitude should be less than right longitude"; + return nullopt; } left = util::max(-180.0, *left); right = util::min(180.0, *right); |