diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2020-03-20 12:38:09 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2020-03-23 12:09:09 +0200 |
commit | d15b9c1f9c1afa29175ba2e398adc680e66147e6 (patch) | |
tree | 6bf426ae77d7386a6bbdee30444974bbc5dd76d0 /src/mbgl/style | |
parent | 37802eec36aae3cb84c7f73a48652d9959489243 (diff) | |
download | qtlocation-mapboxgl-d15b9c1f9c1afa29175ba2e398adc680e66147e6.tar.gz |
[core] Fix performance-unnecessary-value-param errors
As reported by clang-tidy-8.
Diffstat (limited to 'src/mbgl/style')
27 files changed, 249 insertions, 193 deletions
diff --git a/src/mbgl/style/conversion/filter.cpp b/src/mbgl/style/conversion/filter.cpp index 0a10d1e80a..d665a4b22e 100644 --- a/src/mbgl/style/conversion/filter.cpp +++ b/src/mbgl/style/conversion/filter.cpp @@ -1,11 +1,12 @@ #include <mbgl/style/conversion/filter.hpp> #include <mbgl/style/conversion_impl.hpp> -#include <mbgl/style/expression/literal.hpp> +#include <mbgl/style/expression/boolean_operator.hpp> +#include <mbgl/style/expression/compound_expression.hpp> #include <mbgl/style/expression/expression.hpp> +#include <mbgl/style/expression/literal.hpp> #include <mbgl/style/expression/type.hpp> -#include <mbgl/style/expression/compound_expression.hpp> -#include <mbgl/style/expression/boolean_operator.hpp> #include <mbgl/util/geometry.hpp> +#include <utility> namespace mbgl { namespace style { @@ -78,7 +79,9 @@ bool isExpression(const Convertible& filter) { } } -ParseResult createExpression(std::string op, optional<std::vector<std::unique_ptr<Expression>>> args, Error& error) { +ParseResult createExpression(const std::string& op, + optional<std::vector<std::unique_ptr<Expression>>> args, + Error& error) { if (!args) return {}; assert(std::all_of(args->begin(), args->end(), [](const std::unique_ptr<Expression> &e) { return bool(e.get()); @@ -100,7 +103,7 @@ ParseResult createExpression(std::string op, optional<std::vector<std::unique_pt } } -ParseResult createExpression(std::string op, ParseResult arg, Error& error) { +ParseResult createExpression(const std::string& op, ParseResult arg, Error& error) { if (!arg) { return {}; } @@ -134,7 +137,9 @@ optional<std::vector<std::unique_ptr<Expression>>> convertLiteralArray(const Con return {std::move(output)}; } -ParseResult convertLegacyComparisonFilter(const Convertible& values, Error& error, optional<std::string> opOverride = {}) { +ParseResult convertLegacyComparisonFilter(const Convertible& values, + Error& error, + const optional<std::string>& opOverride = {}) { optional<std::string> op = opOverride ? opOverride : toString(arrayMember(values, 0)); optional<std::string> property = toString(arrayMember(values, 1)); diff --git a/src/mbgl/style/conversion/function.cpp b/src/mbgl/style/conversion/function.cpp index e3beb44d22..6c2bcdf10f 100644 --- a/src/mbgl/style/conversion/function.cpp +++ b/src/mbgl/style/conversion/function.cpp @@ -12,6 +12,7 @@ #include <mbgl/util/string.hpp> #include <cassert> +#include <utility> namespace mbgl { namespace style { @@ -320,7 +321,7 @@ static optional<std::unique_ptr<Expression>> convertLiteral(type::Type type, con }); } -static optional<std::map<double, std::unique_ptr<Expression>>> convertStops(type::Type type, +static optional<std::map<double, std::unique_ptr<Expression>>> convertStops(const type::Type& type, const Convertible& value, Error& error, bool convertTokens) { @@ -382,7 +383,7 @@ static void omitFirstStop(std::map<double, std::unique_ptr<Expression>>& stops) } template <class T> -optional<std::map<T, std::unique_ptr<Expression>>> convertBranches(type::Type type, +optional<std::map<T, std::unique_ptr<Expression>>> convertBranches(const type::Type& type, const Convertible& value, Error& error) { auto stopsValue = objectMember(value, "stops"); @@ -447,13 +448,15 @@ static optional<double> convertBase(const Convertible& value, Error& error) { return *base; } -static std::unique_ptr<Expression> step(type::Type type, std::unique_ptr<Expression> input, std::map<double, std::unique_ptr<Expression>> stops) { +static std::unique_ptr<Expression> step(const type::Type& type, + std::unique_ptr<Expression> input, + std::map<double, std::unique_ptr<Expression>> stops) { return std::make_unique<Step>(type, std::move(input), std::move(stops)); } static std::unique_ptr<Expression> interpolate(type::Type type, Interpolator interpolator, std::unique_ptr<Expression> input, std::map<double, std::unique_ptr<Expression>> stops) { ParsingContext ctx; - auto result = createInterpolate(type, std::move(interpolator), std::move(input), std::move(stops), ctx); + auto result = createInterpolate(std::move(type), std::move(interpolator), std::move(input), std::move(stops), ctx); if (!result) { assert(false); return {}; @@ -462,7 +465,7 @@ static std::unique_ptr<Expression> interpolate(type::Type type, Interpolator int } template <class T> -std::unique_ptr<Expression> categorical(type::Type type, +std::unique_ptr<Expression> categorical(const type::Type& type, const std::string& property, std::map<T, std::unique_ptr<Expression>> branches, std::unique_ptr<Expression> def) { @@ -477,7 +480,7 @@ std::unique_ptr<Expression> categorical(type::Type type, } template <> -std::unique_ptr<Expression> categorical<bool>(type::Type type, +std::unique_ptr<Expression> categorical<bool>(const type::Type& type, const std::string& property, std::map<bool, std::unique_ptr<Expression>> branches, std::unique_ptr<Expression> def) { @@ -499,7 +502,7 @@ std::unique_ptr<Expression> categorical<bool>(type::Type type, def ? std::move(def) : error("replaced with default")); } -static std::unique_ptr<Expression> numberOrDefault(type::Type type, +static std::unique_ptr<Expression> numberOrDefault(const type::Type& type, std::unique_ptr<Expression> get, std::unique_ptr<Expression> expr, std::unique_ptr<Expression> def) { @@ -513,12 +516,13 @@ static std::unique_ptr<Expression> numberOrDefault(type::Type type, return std::make_unique<Case>(type, std::move(branches), std::move(def)); } -static optional<std::unique_ptr<Expression>> convertIntervalFunction(type::Type type, - const Convertible& value, - Error& error, - std::function<std::unique_ptr<Expression> (bool)> makeInput, - std::unique_ptr<Expression> def, - bool convertTokens = false) { +static optional<std::unique_ptr<Expression>> convertIntervalFunction( + const type::Type& type, + const Convertible& value, + Error& error, + const std::function<std::unique_ptr<Expression>(bool)>& makeInput, + std::unique_ptr<Expression> def, + bool convertTokens = false) { auto stops = convertStops(type, value, error, convertTokens); if (!stops) { return nullopt; @@ -531,12 +535,13 @@ static optional<std::unique_ptr<Expression>> convertIntervalFunction(type::Type std::move(def)); } -static optional<std::unique_ptr<Expression>> convertExponentialFunction(type::Type type, - const Convertible& value, - Error& error, - std::function<std::unique_ptr<Expression> (bool)> makeInput, - std::unique_ptr<Expression> def, - bool convertTokens = false) { +static optional<std::unique_ptr<Expression>> convertExponentialFunction( + const type::Type& type, + const Convertible& value, + Error& error, + const std::function<std::unique_ptr<Expression>(bool)>& makeInput, + std::unique_ptr<Expression> def, + bool convertTokens = false) { auto stops = convertStops(type, value, error, convertTokens); if (!stops) { return nullopt; @@ -552,7 +557,7 @@ static optional<std::unique_ptr<Expression>> convertExponentialFunction(type::Ty std::move(def)); } -static optional<std::unique_ptr<Expression>> convertCategoricalFunction(type::Type type, +static optional<std::unique_ptr<Expression>> convertCategoricalFunction(const type::Type& type, const Convertible& value, Error& err, const std::string& property, @@ -849,9 +854,13 @@ optional<std::unique_ptr<Expression>> convertFunctionToExpression(type::Type typ if (toBool(*sourceValue)) { switch (functionType) { case FunctionType::Categorical: - return composite<bool>(type, value, err, [&] (type::Type type_, double, std::map<bool, std::unique_ptr<Expression>> stops) { - return categorical<bool>(type_, *property, std::move(stops), defaultExpr()); - }); + return composite<bool>( + type, + value, + err, + [&](const type::Type& type_, double, std::map<bool, std::unique_ptr<Expression>> stops) { + return categorical<bool>(type_, *property, std::move(stops), defaultExpr()); + }); default: err.message = "unsupported function type"; return nullopt; @@ -861,24 +870,35 @@ optional<std::unique_ptr<Expression>> convertFunctionToExpression(type::Type typ if (toNumber(*sourceValue)) { switch (functionType) { case FunctionType::Interval: - return composite<double>(type, value, err, [&] (type::Type type_, double, std::map<double, std::unique_ptr<Expression>> stops) { - omitFirstStop(stops); - return numberOrDefault(type, - getProperty(false), - step(type_, getProperty(true), std::move(stops)), - defaultExpr()); - }); + return composite<double>( + type, + value, + err, + [&](const type::Type& type_, double, std::map<double, std::unique_ptr<Expression>> stops) { + omitFirstStop(stops); + return numberOrDefault( + type, getProperty(false), step(type_, getProperty(true), std::move(stops)), defaultExpr()); + }); case FunctionType::Exponential: - return composite<double>(type, value, err, [&] (type::Type type_, double base, std::map<double, std::unique_ptr<Expression>> stops) { - return numberOrDefault(type, - getProperty(false), - interpolate(type_, exponential(base), getProperty(true), std::move(stops)), - defaultExpr()); - }); + return composite<double>( + type, + value, + err, + [&](type::Type type_, double base, std::map<double, std::unique_ptr<Expression>> stops) { + return numberOrDefault( + type, + getProperty(false), + interpolate(std::move(type_), exponential(base), getProperty(true), std::move(stops)), + defaultExpr()); + }); case FunctionType::Categorical: - return composite<int64_t>(type, value, err, [&] (type::Type type_, double, std::map<int64_t, std::unique_ptr<Expression>> stops) { - return categorical<int64_t>(type_, *property, std::move(stops), defaultExpr()); - }); + return composite<int64_t>( + type, + value, + err, + [&](const type::Type& type_, double, std::map<int64_t, std::unique_ptr<Expression>> stops) { + return categorical<int64_t>(type_, *property, std::move(stops), defaultExpr()); + }); default: err.message = "unsupported function type"; return nullopt; @@ -888,9 +908,13 @@ optional<std::unique_ptr<Expression>> convertFunctionToExpression(type::Type typ if (toString(*sourceValue)) { switch (functionType) { case FunctionType::Categorical: - return composite<std::string>(type, value, err, [&] (type::Type type_, double, std::map<std::string, std::unique_ptr<Expression>> stops) { - return categorical<std::string>(type_, *property, std::move(stops), defaultExpr()); - }); + return composite<std::string>( + type, + value, + err, + [&](const type::Type& type_, double, std::map<std::string, std::unique_ptr<Expression>> stops) { + return categorical<std::string>(type_, *property, std::move(stops), defaultExpr()); + }); default: err.message = "unsupported function type"; return nullopt; diff --git a/src/mbgl/style/custom_tile_loader.cpp b/src/mbgl/style/custom_tile_loader.cpp index a266e60cfc..d0b4dd58bc 100644 --- a/src/mbgl/style/custom_tile_loader.cpp +++ b/src/mbgl/style/custom_tile_loader.cpp @@ -10,7 +10,7 @@ CustomTileLoader::CustomTileLoader(const TileFunction& fetchTileFn, const TileFu cancelTileFunction = cancelTileFn; } -void CustomTileLoader::fetchTile(const OverscaledTileID& tileID, ActorRef<CustomGeometryTile> tileRef) { +void CustomTileLoader::fetchTile(const OverscaledTileID& tileID, const ActorRef<CustomGeometryTile>& tileRef) { std::lock_guard<std::mutex> guard(dataMutex); auto cachedTileData = dataCache.find(tileID.canonical); if (cachedTileData != dataCache.end()) { diff --git a/src/mbgl/style/custom_tile_loader.hpp b/src/mbgl/style/custom_tile_loader.hpp index 7d2d5cffe6..b27a8a1521 100644 --- a/src/mbgl/style/custom_tile_loader.hpp +++ b/src/mbgl/style/custom_tile_loader.hpp @@ -21,7 +21,7 @@ public: CustomTileLoader(const TileFunction& fetchTileFn, const TileFunction& cancelTileFn); - void fetchTile(const OverscaledTileID& tileID, ActorRef<CustomGeometryTile> tileRef); + void fetchTile(const OverscaledTileID& tileID, const ActorRef<CustomGeometryTile>& tileRef); void cancelTile(const OverscaledTileID& tileID); void removeTile(const OverscaledTileID& tileID); diff --git a/src/mbgl/style/expression/assertion.cpp b/src/mbgl/style/expression/assertion.cpp index 17f8925511..0b69943779 100644 --- a/src/mbgl/style/expression/assertion.cpp +++ b/src/mbgl/style/expression/assertion.cpp @@ -1,6 +1,7 @@ +#include <mbgl/style/conversion_impl.hpp> #include <mbgl/style/expression/assertion.hpp> #include <mbgl/style/expression/check_subtype.hpp> -#include <mbgl/style/conversion_impl.hpp> +#include <utility> namespace mbgl { namespace style { @@ -8,10 +9,8 @@ namespace expression { using namespace mbgl::style::conversion; -Assertion::Assertion(type::Type type_, std::vector<std::unique_ptr<Expression>> inputs_) : - Expression(Kind::Assertion, type_), - inputs(std::move(inputs_)) -{ +Assertion::Assertion(type::Type type_, std::vector<std::unique_ptr<Expression>> inputs_) + : Expression(Kind::Assertion, std::move(type_)), inputs(std::move(inputs_)) { assert(!inputs.empty()); } diff --git a/src/mbgl/style/expression/collator.cpp b/src/mbgl/style/expression/collator.cpp index 185d713150..a5dbc614af 100644 --- a/src/mbgl/style/expression/collator.cpp +++ b/src/mbgl/style/expression/collator.cpp @@ -4,8 +4,8 @@ namespace mbgl { namespace style { namespace expression { -Collator::Collator(bool caseSensitive, bool diacriticSensitive, optional<std::string> locale) - : collator(platform::Collator(caseSensitive, diacriticSensitive, std::move(locale))) {} +Collator::Collator(bool caseSensitive, bool diacriticSensitive, const optional<std::string>& locale) + : collator(platform::Collator(caseSensitive, diacriticSensitive, locale)) {} bool Collator::operator==(const Collator& other) const { return collator == other.collator; diff --git a/src/mbgl/style/expression/comparison.cpp b/src/mbgl/style/expression/comparison.cpp index aa5808a975..ca29ace0dd 100644 --- a/src/mbgl/style/expression/comparison.cpp +++ b/src/mbgl/style/expression/comparison.cpp @@ -22,30 +22,34 @@ static bool isComparableType(const std::string& op, const type::Type& type) { } } -bool eq(Value a, Value b) { return a == b; } -bool neq(Value a, Value b) { return a != b; } -bool lt(Value lhs, Value rhs) { +bool eq(const Value& a, const Value& b) { + return a == b; +} +bool neq(const Value& a, const Value& b) { + return a != b; +} +bool lt(const Value& lhs, const Value& rhs) { return lhs.match( [&](const std::string& a) { return a < rhs.get<std::string>(); }, [&](double a) { return a < rhs.get<double>(); }, [&](const auto&) { assert(false); return false; } ); } -bool gt(Value lhs, Value rhs) { +bool gt(const Value& lhs, const Value& rhs) { return lhs.match( [&](const std::string& a) { return a > rhs.get<std::string>(); }, [&](double a) { return a > rhs.get<double>(); }, [&](const auto&) { assert(false); return false; } ); } -bool lteq(Value lhs, Value rhs) { +bool lteq(const Value& lhs, const Value& rhs) { return lhs.match( [&](const std::string& a) { return a <= rhs.get<std::string>(); }, [&](double a) { return a <= rhs.get<double>(); }, [&](const auto&) { assert(false); return false; } ); } -bool gteq(Value lhs, Value rhs) { +bool gteq(const Value& lhs, const Value& rhs) { return lhs.match( [&](const std::string& a) { return a >= rhs.get<std::string>(); }, [&](double a) { return a >= rhs.get<double>(); }, @@ -53,12 +57,24 @@ bool gteq(Value lhs, Value rhs) { ); } -bool eqCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) == 0; } -bool neqCollate(std::string a, std::string b, Collator c) { return !eqCollate(a, b, c); } -bool ltCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) < 0; } -bool gtCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) > 0; } -bool lteqCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) <= 0; } -bool gteqCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) >= 0; } +bool eqCollate(const std::string& a, const std::string& b, const Collator& c) { + return c.compare(a, b) == 0; +} +bool neqCollate(const std::string& a, const std::string& b, const Collator& c) { + return !eqCollate(a, b, c); +} +bool ltCollate(const std::string& a, const std::string& b, const Collator& c) { + return c.compare(a, b) < 0; +} +bool gtCollate(const std::string& a, const std::string& b, const Collator& c) { + return c.compare(a, b) > 0; +} +bool lteqCollate(const std::string& a, const std::string& b, const Collator& c) { + return c.compare(a, b) <= 0; +} +bool gteqCollate(const std::string& a, const std::string& b, const Collator& c) { + return c.compare(a, b) >= 0; +} static BasicComparison::CompareFunctionType getBasicCompareFunction(const std::string& op) { if (op == "==") return eq; diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index f735f57162..30abe37d2e 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -84,13 +84,11 @@ struct Signature; // Simple evaluate function (const T0&, const T1&, ...) -> Result<U> template <class R, class... Params> struct Signature<R (Params...)> : SignatureBase { - Signature(R (*evaluate_)(Params...), std::string name_) : - SignatureBase( - valueTypeToExpressionType<std::decay_t<typename R::Value>>(), - std::vector<type::Type> {valueTypeToExpressionType<std::decay_t<Params>>()...}, - std::move(name_) - ), - evaluate(evaluate_) {} + Signature(R (*evaluate_)(Params...), const std::string& name_) + : SignatureBase(valueTypeToExpressionType<std::decay_t<typename R::Value>>(), + std::vector<type::Type>{valueTypeToExpressionType<std::decay_t<Params>>()...}, + name_), + evaluate(evaluate_) {} EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const override { return applyImpl(evaluationParameters, args, std::index_sequence_for<Params...>{}); @@ -116,14 +114,11 @@ private: // Varargs evaluate function (const Varargs<T>&) -> Result<U> template <class R, typename T> struct Signature<R (const Varargs<T>&)> : SignatureBase { - Signature(R (*evaluate_)(const Varargs<T>&), std::string name_) : - SignatureBase( - valueTypeToExpressionType<std::decay_t<typename R::Value>>(), - VarargsType { valueTypeToExpressionType<T>() }, - std::move(name_) - ), - evaluate(evaluate_) - {} + Signature(R (*evaluate_)(const Varargs<T>&), const std::string& name_) + : SignatureBase(valueTypeToExpressionType<std::decay_t<typename R::Value>>(), + VarargsType{valueTypeToExpressionType<T>()}, + name_), + evaluate(evaluate_) {} EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const override { Varargs<T> evaluated; @@ -145,14 +140,11 @@ struct Signature<R (const Varargs<T>&)> : SignatureBase { // (const EvaluationParams&, const T0&, const T1&, ...) -> Result<U> template <class R, class... Params> struct Signature<R (const EvaluationContext&, Params...)> : SignatureBase { - Signature(R (*evaluate_)(const EvaluationContext&, Params...), std::string name_) : - SignatureBase( - valueTypeToExpressionType<std::decay_t<typename R::Value>>(), - std::vector<type::Type> {valueTypeToExpressionType<std::decay_t<Params>>()...}, - std::move(name_) - ), - evaluate(evaluate_) - {} + Signature(R (*evaluate_)(const EvaluationContext&, Params...), const std::string& name_) + : SignatureBase(valueTypeToExpressionType<std::decay_t<typename R::Value>>(), + std::vector<type::Type>{valueTypeToExpressionType<std::decay_t<Params>>()...}, + name_), + evaluate(evaluate_) {} EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const override { return applyImpl(evaluationParameters, args, std::index_sequence_for<Params...>{}); @@ -179,14 +171,11 @@ private: // (const EvaluationContext&, const Varargs<T>&) -> Result<U> template <class R, typename T> struct Signature<R (const EvaluationContext&, const Varargs<T>&)> : SignatureBase { - Signature(R (*evaluate_)(const EvaluationContext&, const Varargs<T>&), std::string name_) : - SignatureBase( - valueTypeToExpressionType<std::decay_t<typename R::Value>>(), - VarargsType { valueTypeToExpressionType<T>() }, - std::move(name_) - ), - evaluate(evaluate_) - {} + Signature(R (*evaluate_)(const EvaluationContext&, const Varargs<T>&), const std::string& name_) + : SignatureBase(valueTypeToExpressionType<std::decay_t<typename R::Value>>(), + VarargsType{valueTypeToExpressionType<T>()}, + name_), + evaluate(evaluate_) {} EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const override { Varargs<T> evaluated; @@ -223,7 +212,7 @@ static std::unique_ptr<detail::SignatureBase> makeSignature(std::string name, Fn } // namespace detail -Value featureIdAsExpressionValue(EvaluationContext params) { +Value featureIdAsExpressionValue(const EvaluationContext& params) { assert(params.feature); auto id = params.feature->getID(); if (id.is<NullValue>()) return Null; @@ -232,7 +221,7 @@ Value featureIdAsExpressionValue(EvaluationContext params) { }); }; -optional<Value> featurePropertyAsExpressionValue(EvaluationContext params, const std::string& key) { +optional<Value> featurePropertyAsExpressionValue(const EvaluationContext& params, const std::string& key) { assert(params.feature); auto property = params.feature->getValue(key); return property ? toExpressionValue(*property) : optional<Value>(); @@ -253,7 +242,7 @@ optional<std::string> featureTypeAsString(FeatureType type) { } }; -optional<double> featurePropertyAsDouble(EvaluationContext params, const std::string& key) { +optional<double> featurePropertyAsDouble(const EvaluationContext& params, const std::string& key) { assert(params.feature); auto property = params.feature->getValue(key); if (!property) return {}; @@ -265,7 +254,7 @@ optional<double> featurePropertyAsDouble(EvaluationContext params, const std::st ); }; -optional<std::string> featurePropertyAsString(EvaluationContext params, const std::string& key) { +optional<std::string> featurePropertyAsString(const EvaluationContext& params, const std::string& key) { assert(params.feature); auto property = params.feature->getValue(key); if (!property) return {}; @@ -275,7 +264,7 @@ optional<std::string> featurePropertyAsString(EvaluationContext params, const st ); }; -optional<double> featureIdAsDouble(EvaluationContext params) { +optional<double> featureIdAsDouble(const EvaluationContext& params) { assert(params.feature); auto id = params.feature->getID(); return id.match( @@ -286,7 +275,7 @@ optional<double> featureIdAsDouble(EvaluationContext params) { ); }; -optional<std::string> featureIdAsString(EvaluationContext params) { +optional<std::string> featureIdAsString(const EvaluationContext& params) { assert(params.feature); auto id = params.feature->getID(); return id.match( @@ -723,10 +712,12 @@ const auto& filterLessThanNumberCompoundExpression() { } const auto& filterLessThanStringCompoundExpression() { - static auto signature = detail::makeSignature("filter-<", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> { - auto rhs = featurePropertyAsString(params, key); - return rhs ? rhs < lhs : false; - }); + static auto signature = detail::makeSignature( + "filter-<", + [](const EvaluationContext& params, const std::string& key, const std::string& lhs) -> Result<bool> { + auto rhs = featurePropertyAsString(params, key); + return rhs ? rhs < lhs : false; + }); return signature; } @@ -739,10 +730,11 @@ const auto& filterIdLessThanNumberCompoundExpression() { } const auto& filterIdLessThanStringCompoundExpression() { - static auto signature = detail::makeSignature("filter-id-<", [](const EvaluationContext& params, std::string lhs) -> Result<bool> { - auto rhs = featureIdAsString(params); - return rhs ? rhs < lhs : false; - }); + static auto signature = detail::makeSignature( + "filter-id-<", [](const EvaluationContext& params, const std::string& lhs) -> Result<bool> { + auto rhs = featureIdAsString(params); + return rhs ? rhs < lhs : false; + }); return signature; } @@ -755,10 +747,12 @@ const auto& filterMoreThanNumberCompoundExpression() { } const auto& filterMoreThanStringCompoundExpression() { - static auto signature = detail::makeSignature("filter->", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> { - auto rhs = featurePropertyAsString(params, key); - return rhs ? rhs > lhs : false; - }); + static auto signature = detail::makeSignature( + "filter->", + [](const EvaluationContext& params, const std::string& key, const std::string& lhs) -> Result<bool> { + auto rhs = featurePropertyAsString(params, key); + return rhs ? rhs > lhs : false; + }); return signature; } @@ -771,10 +765,11 @@ const auto& filterIdMoreThanNumberCompoundExpression() { } const auto& filterIdMoreThanStringCompoundExpression() { - static auto signature = detail::makeSignature("filter-id->", [](const EvaluationContext& params, std::string lhs) -> Result<bool> { - auto rhs = featureIdAsString(params); - return rhs ? rhs > lhs : false; - }); + static auto signature = detail::makeSignature( + "filter-id->", [](const EvaluationContext& params, const std::string& lhs) -> Result<bool> { + auto rhs = featureIdAsString(params); + return rhs ? rhs > lhs : false; + }); return signature; } @@ -787,10 +782,12 @@ const auto& filterLessOrEqualThanNumberCompoundExpression() { } const auto& filterLessOrEqualThanStringCompoundExpression() { - static auto signature = detail::makeSignature("filter-<=", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> { - auto rhs = featurePropertyAsString(params, key); - return rhs ? rhs <= lhs : false; - }); + static auto signature = detail::makeSignature( + "filter-<=", + [](const EvaluationContext& params, const std::string& key, const std::string& lhs) -> Result<bool> { + auto rhs = featurePropertyAsString(params, key); + return rhs ? rhs <= lhs : false; + }); return signature; } @@ -803,10 +800,11 @@ const auto& filterIdLessOrEqualThanNumberCompoundExpression() { } const auto& filterIdLessOrEqualThanStringCompoundExpression() { - static auto signature = detail::makeSignature("filter-id-<=", [](const EvaluationContext& params, std::string lhs) -> Result<bool> { - auto rhs = featureIdAsString(params); - return rhs ? rhs <= lhs : false; - }); + static auto signature = detail::makeSignature( + "filter-id-<=", [](const EvaluationContext& params, const std::string& lhs) -> Result<bool> { + auto rhs = featureIdAsString(params); + return rhs ? rhs <= lhs : false; + }); return signature; } @@ -819,10 +817,12 @@ const auto& filterGreaterOrEqualThanNumberCompoundExpression() { } const auto& filterGreaterOrEqualThanStringCompoundExpression() { - static auto signature = detail::makeSignature("filter->=", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> { - auto rhs = featurePropertyAsString(params, key); - return rhs ? rhs >= lhs : false; - }); + static auto signature = detail::makeSignature( + "filter->=", + [](const EvaluationContext& params, const std::string& key, const std::string& lhs) -> Result<bool> { + auto rhs = featurePropertyAsString(params, key); + return rhs ? rhs >= lhs : false; + }); return signature; } @@ -835,10 +835,11 @@ const auto& filterIdGreaterOrEqualThanNumberCompoundExpression() { } const auto& filterIdGreaterOrEqualThanStringCompoundExpression() { - static auto signature = detail::makeSignature("filter-id->=", [](const EvaluationContext& params, std::string lhs) -> Result<bool> { - auto rhs = featureIdAsString(params); - return rhs ? rhs >= lhs : false; - }); + static auto signature = detail::makeSignature( + "filter-id->=", [](const EvaluationContext& params, const std::string& lhs) -> Result<bool> { + auto rhs = featureIdAsString(params); + return rhs ? rhs >= lhs : false; + }); return signature; } @@ -1065,7 +1066,7 @@ static ParseResult createCompoundExpression(const Definitions& definitions, return ParseResult(); } -ParseResult parseCompoundExpression(const std::string name, const Convertible& value, ParsingContext& ctx) { +ParseResult parseCompoundExpression(const std::string& name, const Convertible& value, ParsingContext& ctx) { assert(isArray(value) && arrayLength(value) > 0); const auto definitions = compoundExpressionRegistry.equal_range(name.c_str()); diff --git a/src/mbgl/style/expression/dsl.cpp b/src/mbgl/style/expression/dsl.cpp index c8d98e61a4..d8c105633f 100644 --- a/src/mbgl/style/expression/dsl.cpp +++ b/src/mbgl/style/expression/dsl.cpp @@ -11,9 +11,10 @@ #include <mbgl/style/expression/literal.hpp> #include <mbgl/style/expression/step.hpp> +#include <rapidjson/document.h> #include <mapbox/geojsonvt.hpp> #include <mbgl/style/conversion/json.hpp> -#include <rapidjson/document.h> +#include <utility> namespace mbgl { namespace style { @@ -54,7 +55,7 @@ std::unique_ptr<Expression> literal(const char* value) { return literal(std::string(value)); } -std::unique_ptr<Expression> literal(Value value) { +std::unique_ptr<Expression> literal(const Value& value) { return std::make_unique<Literal>(value); } @@ -74,7 +75,7 @@ std::unique_ptr<Expression> literal(std::initializer_list<const char *> value) { return literal(values); } -std::unique_ptr<Expression> assertion(type::Type type, +std::unique_ptr<Expression> assertion(const type::Type& type, std::unique_ptr<Expression> value, std::unique_ptr<Expression> def) { std::vector<std::unique_ptr<Expression>> v = vec(std::move(value)); @@ -99,7 +100,7 @@ std::unique_ptr<Expression> boolean(std::unique_ptr<Expression> value, return assertion(type::Boolean, std::move(value), std::move(def)); } -std::unique_ptr<Expression> coercion(type::Type type, +std::unique_ptr<Expression> coercion(const type::Type& type, std::unique_ptr<Expression> value, std::unique_ptr<Expression> def) { std::vector<std::unique_ptr<Expression>> v = vec(std::move(value)); @@ -193,7 +194,7 @@ std::unique_ptr<Expression> interpolate(Interpolator interpolator, std::map<double, std::unique_ptr<Expression>> stops; stops[input1] = std::move(output1); ParsingContext ctx; - ParseResult result = createInterpolate(type, interpolator, std::move(input), std::move(stops), ctx); + ParseResult result = createInterpolate(type, std::move(interpolator), std::move(input), std::move(stops), ctx); assert(result); return std::move(*result); } @@ -207,7 +208,7 @@ std::unique_ptr<Expression> interpolate(Interpolator interpolator, stops[input1] = std::move(output1); stops[input2] = std::move(output2); ParsingContext ctx; - ParseResult result = createInterpolate(type, interpolator, std::move(input), std::move(stops), ctx); + ParseResult result = createInterpolate(type, std::move(interpolator), std::move(input), std::move(stops), ctx); assert(result); return std::move(*result); } @@ -223,7 +224,7 @@ std::unique_ptr<Expression> interpolate(Interpolator interpolator, stops[input2] = std::move(output2); stops[input3] = std::move(output3); ParsingContext ctx; - ParseResult result = createInterpolate(type, interpolator, std::move(input), std::move(stops), ctx); + ParseResult result = createInterpolate(type, std::move(interpolator), std::move(input), std::move(stops), ctx); assert(result); return std::move(*result); } diff --git a/src/mbgl/style/expression/expression.cpp b/src/mbgl/style/expression/expression.cpp index 66e2e30b14..4f5e3848d5 100644 --- a/src/mbgl/style/expression/expression.cpp +++ b/src/mbgl/style/expression/expression.cpp @@ -1,6 +1,7 @@ -#include <mbgl/style/expression/expression.hpp> #include <mbgl/style/expression/compound_expression.hpp> +#include <mbgl/style/expression/expression.hpp> #include <mbgl/tile/geometry_tile_data.hpp> +#include <utility> namespace mbgl { namespace style { @@ -43,7 +44,7 @@ EvaluationResult Expression::evaluate(optional<float> zoom, const Feature& feature, optional<double> colorRampParameter) const { GeoJSONFeature f(feature); - return this->evaluate(EvaluationContext(zoom, &f, colorRampParameter)); + return this->evaluate(EvaluationContext(std::move(zoom), &f, std::move(colorRampParameter))); } EvaluationResult Expression::evaluate(optional<float> zoom, @@ -51,7 +52,8 @@ EvaluationResult Expression::evaluate(optional<float> zoom, optional<double> colorRampParameter, const std::set<std::string>& availableImages) const { GeoJSONFeature f(feature); - return this->evaluate(EvaluationContext(zoom, &f, colorRampParameter).withAvailableImages(&availableImages)); + return this->evaluate( + EvaluationContext(std::move(zoom), &f, std::move(colorRampParameter)).withAvailableImages(&availableImages)); } EvaluationResult Expression::evaluate(optional<float> zoom, @@ -60,14 +62,14 @@ EvaluationResult Expression::evaluate(optional<float> zoom, const std::set<std::string>& availableImages, const CanonicalTileID& canonical) const { GeoJSONFeature f(feature, canonical); - return this->evaluate(EvaluationContext(zoom, &f, colorRampParameter) + return this->evaluate(EvaluationContext(std::move(zoom), &f, std::move(colorRampParameter)) .withAvailableImages(&availableImages) .withCanonicalTileID(&canonical)); } EvaluationResult Expression::evaluate(optional<mbgl::Value> accumulated, const Feature& feature) const { GeoJSONFeature f(feature); - return this->evaluate(EvaluationContext(accumulated, &f)); + return this->evaluate(EvaluationContext(std::move(accumulated), &f)); } } // namespace expression diff --git a/src/mbgl/style/expression/in.cpp b/src/mbgl/style/expression/in.cpp index fa2bd83656..f77a0b7f91 100644 --- a/src/mbgl/style/expression/in.cpp +++ b/src/mbgl/style/expression/in.cpp @@ -9,20 +9,20 @@ namespace style { namespace expression { namespace { -bool isComparableType(type::Type type) { +bool isComparableType(const type::Type& type) { return type == type::Boolean || type == type::String || type == type::Number || type == type::Null || type == type::Value; } -bool isComparableRuntimeType(type::Type type) { +bool isComparableRuntimeType(const type::Type& type) { return type == type::Boolean || type == type::String || type == type::Number || type == type::Null; } -bool isSearchableType(type::Type type) { +bool isSearchableType(const type::Type& type) { return type == type::String || type.is<type::Array>() || type == type::Null || type == type::Value; } -bool isSearchableRuntimeType(type::Type type) { +bool isSearchableRuntimeType(const type::Type& type) { return type == type::String || type.is<type::Array>() || type == type::Null; } } // namespace diff --git a/src/mbgl/style/expression/interpolate.cpp b/src/mbgl/style/expression/interpolate.cpp index 8725e9e86d..3a7c76819d 100644 --- a/src/mbgl/style/expression/interpolate.cpp +++ b/src/mbgl/style/expression/interpolate.cpp @@ -11,12 +11,12 @@ using namespace mbgl::style::conversion; template <typename T> class InterpolateImpl : public Interpolate { public: - InterpolateImpl(type::Type type_, - Interpolator interpolator_, - std::unique_ptr<Expression> input_, - std::map<double, std::unique_ptr<Expression>> stops_ - ) : Interpolate(std::move(type_), std::move(interpolator_), std::move(input_), std::move(stops_)) - { + InterpolateImpl(const type::Type& type_, + const Interpolator& interpolator_, + std::unique_ptr<Expression> input_, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::map<double, std::unique_ptr<Expression>> stops_) + : Interpolate(type_, interpolator_, std::move(input_), std::move(stops_)) { static_assert(util::Interpolatable<T>::value, "Interpolate expression requires an interpolatable value type."); } diff --git a/src/mbgl/style/expression/parsing_context.cpp b/src/mbgl/style/expression/parsing_context.cpp index 2f1e1c1820..ad1a46b8d6 100644 --- a/src/mbgl/style/expression/parsing_context.cpp +++ b/src/mbgl/style/expression/parsing_context.cpp @@ -34,6 +34,7 @@ #include <mbgl/util/string.hpp> #include <mapbox/eternal.hpp> +#include <utility> namespace mbgl { namespace style { @@ -85,7 +86,7 @@ using namespace mbgl::style::conversion; ParseResult ParsingContext::parse(const Convertible& value, std::size_t index_, optional<type::Type> expected_, - optional<TypeAnnotationOption> typeAnnotationOption) { + const optional<TypeAnnotationOption>& typeAnnotationOption) { ParsingContext child(key + "[" + util::toString(index_) + "]", errors, std::move(expected_), @@ -144,7 +145,8 @@ bool isExpression(const std::string& name) { return expressionRegistry.contains(name.c_str()); } -ParseResult ParsingContext::parse(const Convertible& value, optional<TypeAnnotationOption> typeAnnotationOption) { +ParseResult ParsingContext::parse(const Convertible& value, + const optional<TypeAnnotationOption>& typeAnnotationOption) { ParseResult parsed; if (isArray(value)) { @@ -179,14 +181,16 @@ ParseResult ParsingContext::parse(const Convertible& value, optional<TypeAnnotat return parsed; } - auto annotate = [] (std::unique_ptr<Expression> expression, type::Type type, TypeAnnotationOption typeAnnotation) -> std::unique_ptr<Expression> { + auto annotate = [](std::unique_ptr<Expression> expression, + const type::Type& type, + TypeAnnotationOption typeAnnotation) -> std::unique_ptr<Expression> { switch (typeAnnotation) { - case TypeAnnotationOption::assert: - return std::make_unique<Assertion>(type, dsl::vec(std::move(expression))); - case TypeAnnotationOption::coerce: - return std::make_unique<Coercion>(type, dsl::vec(std::move(expression))); - case TypeAnnotationOption::omit: - return expression; + case TypeAnnotationOption::assert: + return std::make_unique<Assertion>(type, dsl::vec(std::move(expression))); + case TypeAnnotationOption::coerce: + return std::make_unique<Coercion>(type, dsl::vec(std::move(expression))); + case TypeAnnotationOption::omit: + return expression; } // Not reachable, but placate GCC. @@ -237,7 +241,8 @@ ParseResult ParsingContext::parse(const Convertible& value, optional<TypeAnnotat return parsed; } -ParseResult ParsingContext::parseExpression(const Convertible& value, optional<TypeAnnotationOption> typeAnnotationOption) { +ParseResult ParsingContext::parseExpression(const Convertible& value, + const optional<TypeAnnotationOption>& typeAnnotationOption) { return parse(value, typeAnnotationOption); } diff --git a/src/mbgl/style/image.cpp b/src/mbgl/style/image.cpp index be7e52abfa..eb0b5ab24b 100644 --- a/src/mbgl/style/image.cpp +++ b/src/mbgl/style/image.cpp @@ -11,7 +11,7 @@ Image::Image(std::string id, bool sdf, ImageStretches stretchX, ImageStretches stretchY, - optional<ImageContent> content) + const optional<ImageContent>& content) : baseImpl(makeMutable<Impl>( std::move(id), std::move(image), pixelRatio, sdf, std::move(stretchX), std::move(stretchY), content)) {} diff --git a/src/mbgl/style/light.cpp b/src/mbgl/style/light.cpp index 2ef4c2f940..e4ceed0ce6 100644 --- a/src/mbgl/style/light.cpp +++ b/src/mbgl/style/light.cpp @@ -12,6 +12,8 @@ #include <mapbox/eternal.hpp> +#include <utility> + namespace mbgl { namespace style { @@ -188,7 +190,7 @@ PropertyValue<LightAnchorType> Light::getAnchor() const { void Light::setAnchor(PropertyValue<LightAnchorType> property) { auto impl_ = mutableImpl(); - impl_->properties.template get<LightAnchor>().value = property; + impl_->properties.template get<LightAnchor>().value = std::move(property); impl = std::move(impl_); observer->onLightChanged(*this); } @@ -214,7 +216,7 @@ PropertyValue<Color> Light::getColor() const { void Light::setColor(PropertyValue<Color> property) { auto impl_ = mutableImpl(); - impl_->properties.template get<LightColor>().value = property; + impl_->properties.template get<LightColor>().value = std::move(property); impl = std::move(impl_); observer->onLightChanged(*this); } @@ -240,7 +242,7 @@ PropertyValue<float> Light::getIntensity() const { void Light::setIntensity(PropertyValue<float> property) { auto impl_ = mutableImpl(); - impl_->properties.template get<LightIntensity>().value = property; + impl_->properties.template get<LightIntensity>().value = std::move(property); impl = std::move(impl_); observer->onLightChanged(*this); } @@ -266,7 +268,7 @@ PropertyValue<Position> Light::getPosition() const { void Light::setPosition(PropertyValue<Position> property) { auto impl_ = mutableImpl(); - impl_->properties.template get<LightPosition>().value = property; + impl_->properties.template get<LightPosition>().value = std::move(property); impl = std::move(impl_); observer->onLightChanged(*this); } diff --git a/src/mbgl/style/light.cpp.ejs b/src/mbgl/style/light.cpp.ejs index 9f84238839..fb0c47dc62 100644 --- a/src/mbgl/style/light.cpp.ejs +++ b/src/mbgl/style/light.cpp.ejs @@ -15,6 +15,8 @@ #include <mapbox/eternal.hpp> +#include <utility> + namespace mbgl { namespace style { @@ -142,7 +144,7 @@ StyleProperty Light::getProperty(const std::string& name) const { void Light::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> property) { auto impl_ = mutableImpl(); - impl_->properties.template get<Light<%- camelize(property.name) %>>().value = property; + impl_->properties.template get<Light<%- camelize(property.name) %>>().value = std::move(property); impl = std::move(impl_); observer->onLightChanged(*this); } diff --git a/src/mbgl/style/sources/custom_geometry_source.cpp b/src/mbgl/style/sources/custom_geometry_source.cpp index 44401c1a8f..9d3a58c151 100644 --- a/src/mbgl/style/sources/custom_geometry_source.cpp +++ b/src/mbgl/style/sources/custom_geometry_source.cpp @@ -14,7 +14,7 @@ namespace mbgl { namespace style { -CustomGeometrySource::CustomGeometrySource(std::string id, CustomGeometrySource::Options options) +CustomGeometrySource::CustomGeometrySource(std::string id, const CustomGeometrySource::Options& options) : Source(makeMutable<CustomGeometrySource::Impl>(std::move(id), options)), loader(std::make_unique<Actor<CustomTileLoader>>( Scheduler::GetBackground(), options.fetchTileFunction, options.cancelTileFunction)) {} diff --git a/src/mbgl/style/sources/custom_geometry_source_impl.cpp b/src/mbgl/style/sources/custom_geometry_source_impl.cpp index e456bd8719..184718fd76 100644 --- a/src/mbgl/style/sources/custom_geometry_source_impl.cpp +++ b/src/mbgl/style/sources/custom_geometry_source_impl.cpp @@ -4,13 +4,13 @@ namespace mbgl { namespace style { -CustomGeometrySource::Impl::Impl(std::string id_, CustomGeometrySource::Options options) +CustomGeometrySource::Impl::Impl(std::string id_, const CustomGeometrySource::Options& options) : Source::Impl(SourceType::CustomVector, std::move(id_)), tileOptions(makeMutable<CustomGeometrySource::TileOptions>(options.tileOptions)), zoomRange(options.zoomRange), loaderRef({}) {} -CustomGeometrySource::Impl::Impl(const Impl& impl, ActorRef<CustomTileLoader> loaderRef_) +CustomGeometrySource::Impl::Impl(const Impl& impl, const ActorRef<CustomTileLoader>& loaderRef_) : Source::Impl(impl), tileOptions(impl.tileOptions), zoomRange(impl.zoomRange), loaderRef(loaderRef_) {} bool CustomGeometrySource::Impl::operator!=(const Impl& other) const noexcept { diff --git a/src/mbgl/style/sources/custom_geometry_source_impl.hpp b/src/mbgl/style/sources/custom_geometry_source_impl.hpp index 04e301f198..a441b38f69 100644 --- a/src/mbgl/style/sources/custom_geometry_source_impl.hpp +++ b/src/mbgl/style/sources/custom_geometry_source_impl.hpp @@ -10,8 +10,8 @@ namespace style { class CustomGeometrySource::Impl : public Source::Impl { public: - Impl(std::string id, CustomGeometrySource::Options options); - Impl(const Impl&, ActorRef<CustomTileLoader>); + Impl(std::string id, const CustomGeometrySource::Options& options); + Impl(const Impl&, const ActorRef<CustomTileLoader>&); optional<std::string> getAttribution() const final; diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 2880b9b131..d750d6b1d2 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -79,7 +79,7 @@ void GeoJSONSource::loadDescription(FileSource& fileSource) { return; } - req = fileSource.request(Resource::source(*url), [this](Response res) { + req = fileSource.request(Resource::source(*url), [this](const Response& res) { if (res.error) { observer->onSourceError( *this, std::make_exception_ptr(std::runtime_error(res.error->message))); diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index bb5445f02b..fb33eee8f9 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -80,7 +80,7 @@ T evaluateFeature(const mapbox::feature::feature<double>& f, // static std::shared_ptr<GeoJSONData> GeoJSONData::create(const GeoJSON& geoJSON, - Immutable<GeoJSONOptions> options, + const Immutable<GeoJSONOptions>& options, std::shared_ptr<Scheduler> scheduler) { constexpr double scale = util::EXTENT / util::tileSize; if (options->cluster && geoJSON.is<Features>() && !geoJSON.get<Features>().empty()) { diff --git a/src/mbgl/style/sources/image_source.cpp b/src/mbgl/style/sources/image_source.cpp index ec727a33bd..144d007cc5 100644 --- a/src/mbgl/style/sources/image_source.cpp +++ b/src/mbgl/style/sources/image_source.cpp @@ -64,7 +64,7 @@ void ImageSource::loadDescription(FileSource& fileSource) { } const Resource imageResource { Resource::Image, *url, {} }; - req = fileSource.request(imageResource, [this](Response res) { + req = fileSource.request(imageResource, [this](const Response& res) { if (res.error) { observer->onSourceError(*this, std::make_exception_ptr(std::runtime_error(res.error->message))); } else if (res.notModified) { diff --git a/src/mbgl/style/sources/raster_dem_source.cpp b/src/mbgl/style/sources/raster_dem_source.cpp index dd859cc6d1..98a83ee870 100644 --- a/src/mbgl/style/sources/raster_dem_source.cpp +++ b/src/mbgl/style/sources/raster_dem_source.cpp @@ -6,13 +6,13 @@ #include <mbgl/style/sources/raster_source_impl.hpp> #include <mbgl/tile/tile.hpp> #include <mbgl/util/mapbox.hpp> +#include <utility> namespace mbgl { namespace style { RasterDEMSource::RasterDEMSource(std::string id, variant<std::string, Tileset> urlOrTileset_, uint16_t tileSize) - : RasterSource(std::move(id), urlOrTileset_, tileSize, SourceType::RasterDEM){ -} + : RasterSource(std::move(id), std::move(urlOrTileset_), tileSize, SourceType::RasterDEM) {} bool RasterDEMSource::supportsLayerType(const mbgl::style::LayerTypeInfo* info) const { return mbgl::underlying_type(Tile::Kind::RasterDEM) == mbgl::underlying_type(info->tileKind); diff --git a/src/mbgl/style/sources/raster_source.cpp b/src/mbgl/style/sources/raster_source.cpp index 8c41da3a23..aa56f9570b 100644 --- a/src/mbgl/style/sources/raster_source.cpp +++ b/src/mbgl/style/sources/raster_source.cpp @@ -53,7 +53,7 @@ void RasterSource::loadDescription(FileSource& fileSource) { } const auto& url = urlOrTileset.get<std::string>(); - req = fileSource.request(Resource::source(url), [this, url](Response res) { + req = fileSource.request(Resource::source(url), [this, url](const Response& res) { if (res.error) { observer->onSourceError(*this, std::make_exception_ptr(std::runtime_error(res.error->message))); } else if (res.notModified) { diff --git a/src/mbgl/style/sources/vector_source.cpp b/src/mbgl/style/sources/vector_source.cpp index cc2319b302..b482449fbf 100644 --- a/src/mbgl/style/sources/vector_source.cpp +++ b/src/mbgl/style/sources/vector_source.cpp @@ -52,7 +52,7 @@ void VectorSource::loadDescription(FileSource& fileSource) { } const auto& url = urlOrTileset.get<std::string>(); - req = fileSource.request(Resource::source(url), [this, url](Response res) { + req = fileSource.request(Resource::source(url), [this, url](const Response& res) { if (res.error) { observer->onSourceError(*this, std::make_exception_ptr(std::runtime_error(res.error->message))); } else if (res.notModified) { diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp index 83570e40e0..52f39b52d4 100644 --- a/src/mbgl/style/style_impl.cpp +++ b/src/mbgl/style/style_impl.cpp @@ -62,7 +62,7 @@ void Style::Impl::loadURL(const std::string& url_) { loaded = false; url = url_; - styleRequest = fileSource->request(Resource::style(url), [this](Response res) { + styleRequest = fileSource->request(Resource::style(url), [this](const Response& res) { // Don't allow a loaded, mutated style to be overwritten with a new version. if (mutated && loaded) { return; @@ -190,7 +190,7 @@ Layer* Style::Impl::getLayer(const std::string& id) const { return layers.get(id); } -Layer* Style::Impl::addLayer(std::unique_ptr<Layer> layer, optional<std::string> before) { +Layer* Style::Impl::addLayer(std::unique_ptr<Layer> layer, const optional<std::string>& before) { // TODO: verify source if (Source* source = sources.get(layer->getSourceID())) { if (!source->supportsLayerType(layer->baseImpl->getTypeInfo())) { diff --git a/src/mbgl/style/style_impl.hpp b/src/mbgl/style/style_impl.hpp index c16b82e90b..4573a3966a 100644 --- a/src/mbgl/style/style_impl.hpp +++ b/src/mbgl/style/style_impl.hpp @@ -65,8 +65,7 @@ public: std::vector<const Layer*> getLayers() const; Layer* getLayer(const std::string& id) const; - Layer* addLayer(std::unique_ptr<Layer>, - optional<std::string> beforeLayerID = {}); + Layer* addLayer(std::unique_ptr<Layer>, const optional<std::string>& beforeLayerID = {}); std::unique_ptr<Layer> removeLayer(const std::string& layerID); std::string getName() const; |