From 9dbd0a666a25b3950d461d41f6c41fc8acea8d81 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 20 Mar 2020 12:38:09 +0200 Subject: [core] Fix modernize-pass-by-value errors As reported by clang-tidy-8. --- include/mbgl/util/feature.hpp | 17 ++++------------- platform/glfw/test_writer.cpp | 3 ++- src/mbgl/renderer/buckets/line_bucket.cpp | 5 +++-- src/mbgl/renderer/buckets/line_bucket.hpp | 2 +- src/mbgl/renderer/buckets/symbol_bucket.cpp | 6 ++++-- src/mbgl/renderer/buckets/symbol_bucket.hpp | 2 +- src/mbgl/style/conversion/get_json_type.cpp | 8 +++----- src/mbgl/style/expression/compound_expression.cpp | 15 +++++---------- 8 files changed, 23 insertions(+), 35 deletions(-) diff --git a/include/mbgl/util/feature.hpp b/include/mbgl/util/feature.hpp index 92d7ebf9da..de9b03f60e 100644 --- a/include/mbgl/util/feature.hpp +++ b/include/mbgl/util/feature.hpp @@ -32,19 +32,10 @@ public: template optional numericValue(const Value& value) { - return value.match( - [] (uint64_t t) { - return optional(t); - }, - [] (int64_t t) { - return optional(t); - }, - [] (double t) { - return optional(t); - }, - [] (auto) { - return optional(); - }); + return value.match([](uint64_t t) { return optional(t); }, + [](int64_t t) { return optional(t); }, + [](double t) { return optional(t); }, + [](const auto&) { return optional(); }); } inline optional featureIDtoString(const FeatureIdentifier& id) { diff --git a/platform/glfw/test_writer.cpp b/platform/glfw/test_writer.cpp index 9debaad643..9fe06cc2ca 100644 --- a/platform/glfw/test_writer.cpp +++ b/platform/glfw/test_writer.cpp @@ -7,6 +7,7 @@ #include #include +#include using Writer = rapidjson::PrettyWriter; @@ -19,7 +20,7 @@ public: class SetCamera final : public TestOperationSerializer { public: - SetCamera(const mbgl::CameraOptions& camera_) : camera(camera_) {} + SetCamera(mbgl::CameraOptions camera_) : camera(std::move(camera_)) {} void serialize(Writer& writer) const override { if (camera.zoom) { diff --git a/src/mbgl/renderer/buckets/line_bucket.cpp b/src/mbgl/renderer/buckets/line_bucket.cpp index 809d8df6d3..256ce35eb5 100644 --- a/src/mbgl/renderer/buckets/line_bucket.cpp +++ b/src/mbgl/renderer/buckets/line_bucket.cpp @@ -5,16 +5,17 @@ #include #include +#include namespace mbgl { using namespace style; -LineBucket::LineBucket(const LineBucket::PossiblyEvaluatedLayoutProperties& layout_, +LineBucket::LineBucket(LineBucket::PossiblyEvaluatedLayoutProperties layout_, const std::map>& layerPaintProperties, const float zoom_, const uint32_t overscaling_) - : layout(layout_), zoom(zoom_), overscaling(overscaling_) { + : layout(std::move(layout_)), zoom(zoom_), overscaling(overscaling_) { for (const auto& pair : layerPaintProperties) { paintPropertyBinders.emplace( std::piecewise_construct, diff --git a/src/mbgl/renderer/buckets/line_bucket.hpp b/src/mbgl/renderer/buckets/line_bucket.hpp index 5b6a65440e..7ddcedef9f 100644 --- a/src/mbgl/renderer/buckets/line_bucket.hpp +++ b/src/mbgl/renderer/buckets/line_bucket.hpp @@ -19,7 +19,7 @@ class LineBucket final : public Bucket { public: using PossiblyEvaluatedLayoutProperties = style::LineLayoutProperties::PossiblyEvaluated; - LineBucket(const PossiblyEvaluatedLayoutProperties& layout, + LineBucket(PossiblyEvaluatedLayoutProperties layout, const std::map>& layerPaintProperties, const float zoom, const uint32_t overscaling); diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index 234e81a9fd..cbdb4bf2ed 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -7,6 +7,8 @@ #include #include +#include + namespace mbgl { using namespace style; @@ -21,7 +23,7 @@ SymbolBucket::SymbolBucket(Immutable&& symbolInstances_, const std::vector&& sortKeyRanges_, float tilePixelRatio_, @@ -29,7 +31,7 @@ SymbolBucket::SymbolBucket(Immutable placementModes_, bool iconsInText_) : layout(std::move(layout_)), - bucketLeaderID(bucketName_), + bucketLeaderID(std::move(bucketName_)), iconsNeedLinear(iconsNeedLinear_ || iconSize.isDataDriven() || !iconSize.isZoomConstant()), sortFeaturesByY(sortFeaturesByY_), staticUploaded(false), diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp index fa845a589a..00ba14589a 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.hpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp @@ -72,7 +72,7 @@ public: float zoom, bool iconsNeedLinear, bool sortFeaturesByY, - const std::string& bucketLeaderID, + std::string bucketLeaderID, const std::vector&&, const std::vector&&, const float tilePixelRatio, diff --git a/src/mbgl/style/conversion/get_json_type.cpp b/src/mbgl/style/conversion/get_json_type.cpp index 2e9d35a957..06becbb121 100644 --- a/src/mbgl/style/conversion/get_json_type.cpp +++ b/src/mbgl/style/conversion/get_json_type.cpp @@ -23,11 +23,9 @@ std::string getJSONType(const Convertible& value) { // conversion succeeds. assert(v); - return v->match( - [&] (const std::string&) { return "string"; }, - [&] (bool) { return "boolean"; }, - [&] (auto) { return "number"; } - ); + return v->match([&](const std::string&) { return "string"; }, + [&](bool) { return "boolean"; }, + [&](const auto&) { return "number"; }); } } // namespace conversion diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index 45b8b793a2..31628617f6 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -249,17 +249,15 @@ optional featurePropertyAsDouble(const EvaluationContext& params, const return property->match([](double value) { return value; }, [](uint64_t value) -> optional { return {static_cast(value)}; }, [](int64_t value) -> optional { return {static_cast(value)}; }, - [](auto) -> optional { return {}; }); + [](const auto&) -> optional { return {}; }); }; optional featurePropertyAsString(const EvaluationContext& params, const std::string& key) { assert(params.feature); auto property = params.feature->getValue(key); if (!property) return {}; - return property->match( - [](std::string value) { return value; }, - [](auto) { return optional(); } - ); + return property->match([](std::string value) { return value; }, + [](const auto&) { return optional(); }); }; optional featureIdAsDouble(const EvaluationContext& params) { @@ -268,16 +266,13 @@ optional featureIdAsDouble(const EvaluationContext& params) { return id.match([](double value) { return value; }, [](uint64_t value) -> optional { return {static_cast(value)}; }, [](int64_t value) -> optional { return {static_cast(value)}; }, - [](auto) -> optional { return {}; }); + [](const auto&) -> optional { return {}; }); }; optional featureIdAsString(const EvaluationContext& params) { assert(params.feature); auto id = params.feature->getID(); - return id.match( - [](std::string value) { return value; }, - [](auto) { return optional(); } - ); + return id.match([](std::string value) { return value; }, [](const auto&) { return optional(); }); }; const auto& eCompoundExpression() { -- cgit v1.2.1